Forum Stats

  • 3,874,218 Users
  • 2,266,685 Discussions
  • 7,911,771 Comments

Discussions

Fetch Variable in Stored in Table

Alter Boy
Alter Boy Member Posts: 65
edited Aug 22, 2018 12:53PM in APEX Discussions

Hi,

So I have a Table, not going to go into too much detail about it because it is fairly irrelevant. All that needs to be known is there is a Varchar2 column, Content, that I intend to be displayed in a text area. So for example, the text may read "My name is Matthew" except I want it to read "Matthew" off of the page that I'm displaying it. Let's say I have a Page with two page items and that's it. The first page item, P129_NAME, holds the value 'Matthew'. The second page item calls Content from the Table. I tried to put, in my Content, "My name is :P129_NAME" so that whoever's name is in that Page Item at that time will be displayed in the Text Area. However, when called it literally displays ":P129_NAME" instead of "Matthew". I also tried &P129_NAME. and the same thing happens. Is there a work-around this?

Thanks,

Matthew

Tagged:

Best Answer

  • fac586
    fac586 Senior Technical Architect Member Posts: 21,456 Red Diamond
    edited Aug 22, 2018 9:54AM Answer ✓
    Alter Boy wrote:I need to do this because the name won't always be "Matthew". It can be any name as there are many possible names in the Table

    It's also the case that it might be desirable to have mail templates that might not always be utilized by an application where there is a P129_EMPLOYEE item, or a session where this has a value in session state. Also, how does the user creating or maintaining the template know that P129_EMPLOYEE is the magic item?

    A more flexible implementation would be to use generic placeholders in the template text:

    For your information there is a new member of staff by the name of %s joining our team

    The application can then use apex_string.format to substitute the placeholder using whatever value is required in the current context:

    apex_string.format(:p129_mail_template, p129_employee)

    so I want the text area to have the person's name that is currently being displayed in the page item.

    Where does that value come from?

Answers

  • fac586
    fac586 Senior Technical Architect Member Posts: 21,456 Red Diamond
    edited Aug 22, 2018 9:03AM
    Alter Boy wrote:So I have a Table, not going to go into too much detail about it because it is fairly irrelevant. All that needs to be known is there is a Varchar2 column, Content, that I intend to be displayed in a text area. So for example, the text may read "My name is Matthew" except I want it to read "Matthew" off of the page that I'm displaying it. Let's say I have a Page with two page items and that's it. The first page item, P129_NAME, holds the value 'Matthew'. The second page item calls Content from the Table. I tried to put, in my Content, "My name is :P129_NAME" so that whoever's name is in that Page Item at that time will be displayed in the Text Area. However, when called it literally displays ":P129_NAME" instead of "Matthew". I also tried &P129_NAME. and the same thing happens. Is there a work-around this?

    The apex_plugin_util.replace_substitutions API method can be used to replace &SUBSTITUTION_STRINGS. in string parameters. This exists to support the creation of APEX plug-ins, which does not appear to be related to the proposed use case. It seems to involve creating dependencies between data and the application in violation of the principle of separation of concerns.

    Why would you need to do this? What problem are you really trying to solve?

  • Alter Boy
    Alter Boy Member Posts: 65
    edited Aug 22, 2018 9:11AM

    I need to do this because the name won't always be "Matthew". It can be any name as there are many possible names in the Table, so I want the text area to have the person's name that is currently being displayed in the page item.

  • Alter Boy
    Alter Boy Member Posts: 65
    edited Aug 22, 2018 9:18AM
  • fac586
    fac586 Senior Technical Architect Member Posts: 21,456 Red Diamond
    edited Aug 22, 2018 9:54AM Answer ✓
    Alter Boy wrote:I need to do this because the name won't always be "Matthew". It can be any name as there are many possible names in the Table

    It's also the case that it might be desirable to have mail templates that might not always be utilized by an application where there is a P129_EMPLOYEE item, or a session where this has a value in session state. Also, how does the user creating or maintaining the template know that P129_EMPLOYEE is the magic item?

    A more flexible implementation would be to use generic placeholders in the template text:

    For your information there is a new member of staff by the name of %s joining our team

    The application can then use apex_string.format to substitute the placeholder using whatever value is required in the current context:

    apex_string.format(:p129_mail_template, p129_employee)

    so I want the text area to have the person's name that is currently being displayed in the page item.

    Where does that value come from?

  • Franck N
    Franck N Member Posts: 1,019 Silver Trophy
    edited Aug 22, 2018 9:42AM

    Hi,

    the Question is ?

    Are you sure the Item :P129_NAME displays the value "Mathiew"?

    how are you fetching  the value form the DB and store it into the Item ?

    -     Set that item to display only and check the Ouput of it on your Page.

    -     Or use apex.item('P129_NAME').getValue(); in your console to check the Value.

    if nothing is getting displayed then there lies the issue.

    regards,

    Franck

  • Alter Boy
    Alter Boy Member Posts: 65
    edited Aug 22, 2018 12:53PM

    The apex_string.format function is all I needed thank you.

This discussion has been closed.