On January 27th, this site will be read-only as we migrate to Oracle Forums for an improved community experience. You will not be able to initiate activity until January 30th, when you will be able to use this site as normal.

    Forum Stats

  • 3,889,629 Users
  • 2,269,769 Discussions
  • 7,916,800 Comments

Discussions

Populate dropdown with previously collected values?

Hi,

I two entities, A and B.

As part of entity A, "location" is collected. Entity B is collected later on in the form, it also has a input for "Location", however I would like this input to be a dropdown with the previously provided values from entity A's "Location" input. Is this possible via OIA? I searched the documentation and the only thing I could find was populating dropdowns from hardcoded values in rules, but nothing regarding dynamically populating based on user input.

I am utilising OIA 21A, with interviews in August 2016 Styling.

Many Thanks

Best Answer

  • Richard Napier
    Richard Napier EuropeMember Posts: 544 Bronze Trophy
    Answer ✓

    Hi There

    Assuming I have interpreted what you have written correctly then hopefully the following will be enough for you and will not require any JavaScript.

    Set up your entities A and B, with Location attributes in both cases.

    Add a relationship between B and A

    Add your data entry Screens for A and B, and add a relationship Control on the Entity B screen to select from the Entity A Instances. Depending on the cardinality, one of the options is to display it as a Dropdown. You can also use substitution to display more text in the control.

    Then you can write a rule to copy the value of the Entity A location to the Entity B location. The exact nature of this rule will depend on the cardinality / context of your scenario

    Run the project and create your Entity A instances.

    In the Entity B data entry, select the correct Location from the dropdown

    The data tab in the Debugger will show you the information thus saved


    As regards your other question, you're right I didn't pay attention to the version you are using - in August 2016 you are limited to old-style custom controls (PHP etc) . See this snippet and link from the current version of the documentation :

    "Customization of interview styling and behavior is performed through a JavaScript-based extension mechanism. (Note that this is different from August 2016 interviews which use custom controls to modify the appearance and behavior of an interview.)"

    Hope that helps.


    User_B5W17

Answers

  • Richard Napier
    Richard Napier EuropeMember Posts: 544 Bronze Trophy
    edited May 14, 2021 4:27PM

    Hi There

    Could you please add a little more detail as to the relationship between entity A and B? Is B a child of A? If so, then we can get the location of B from the parent A no issues.

    It isn't clear whether that is the case, as you mention values for the location of B, which sounds like you want to have multiple instances of A, which let's say produce a set of locations which should then appear as a dropdown on each instance of B. So the relationship between A and B is different.

    Depending on the cardinality and how you need to display the data, a reference relationship and a relationship control to select from might fit the bill since it could provide a list of instances to choose from.

    If it must be a specific layout and a standard- looking drop down It can certainly can be done in JavaScript extension, in that values from an entity A can be used as a dropdown elsewhere in another entity using a custom Options extension. There is an example here https://intelligent-advisor.com/main/custom-options-dynamic-list-of-values/

    If you can confirm the relationship then it may not be necessary to use custom extensions - if it can be done in the out of the box without code so much the better - so let's see.

    Hope this helps

    Richard

    User_B5W17
  • User_B5W17
    User_B5W17 Member Posts: 86 Red Ribbon
    edited Jun 4, 2021 12:25PM

    Hi Richard, many thanks for getting back to me.

    To answer your first question. There can be many instances of entity A, and many instances of Entity B. Entity B's location should always tie back to a matching location of Entity A. Is this possible via default functionality?

    Regarding your second point, can I utilise Javascript extensions when in August 2016 styling mode? I quickly plugged in an example JS file from your site and am given the following error: " ReferenceError: OraclePolicyAutomation is not defined"

    If I try to update the dropdown via jQuery IE:

    $( "select[name$='ListB']" ).append("<option value='Option 3'>Option 3</option>");

    The list updates, but I cannot hit proceed as it fails validation saying this field is mandatory I must provide a value. Almost as if the value is internally validated against the predefined list in OIA.

    Many Thanks

  • Richard Napier
    Richard Napier EuropeMember Posts: 544 Bronze Trophy
    Answer ✓

    Hi There

    Assuming I have interpreted what you have written correctly then hopefully the following will be enough for you and will not require any JavaScript.

    Set up your entities A and B, with Location attributes in both cases.

    Add a relationship between B and A

    Add your data entry Screens for A and B, and add a relationship Control on the Entity B screen to select from the Entity A Instances. Depending on the cardinality, one of the options is to display it as a Dropdown. You can also use substitution to display more text in the control.

    Then you can write a rule to copy the value of the Entity A location to the Entity B location. The exact nature of this rule will depend on the cardinality / context of your scenario

    Run the project and create your Entity A instances.

    In the Entity B data entry, select the correct Location from the dropdown

    The data tab in the Debugger will show you the information thus saved


    As regards your other question, you're right I didn't pay attention to the version you are using - in August 2016 you are limited to old-style custom controls (PHP etc) . See this snippet and link from the current version of the documentation :

    "Customization of interview styling and behavior is performed through a JavaScript-based extension mechanism. (Note that this is different from August 2016 interviews which use custom controls to modify the appearance and behavior of an interview.)"

    Hope that helps.


    User_B5W17
  • User_B5W17
    User_B5W17 Member Posts: 86 Red Ribbon

    Hi Richard,

    Fab, many thanks for this, it has implemented the functionality I desired!


    I do have 2 further questions post implementation of the above:

    Is it possible to make the relationship dropdown location field mandatory?

    If I leave a blank entity instance on the page, and attempt to proceed, the interview ends and states an error occurred. Any idea why this is occurring? If I remove the blank entity instance, or fill it in the form functions as expected.

  • Richard Napier
    Richard Napier EuropeMember Posts: 544 Bronze Trophy

    Hi

    The example wasn't intended as a complete build-out of the scenario, just a brief example. I'm always very uncomfortable providing more detail than that since I have no knowledge of the detailed project context. To keep it generic, therefore :

    You might use a Word Error rule for example, to display a message if the entity B location is not certain. That would stop the user from leaving entity instances with no location. Using substitution in the Error() message will make it clear which instance is the failing one.

    Hope that helps

    Richard

  • User_B5W17
    User_B5W17 Member Posts: 86 Red Ribbon
    edited Jun 8, 2021 10:57AM

    Thanks Richard, I understand and your explanations have been extremely helpful!

    I have one last question on this topic, and entity logic.

    Lets say Entity A has an additional field called "X". It is a dropdown with a value of 1 or 2 (example values)

    Lets say Entity B also has an matching additional field called "X", which also has a dropdown of 1 or 2 (example values)


    Given that Entity B is now choosing its location from the list of Entity A instances, is it possible to bring in further logic such as:


    If the selected Entity A "X"= 1, then Entity B "X" must = 1.

    If selected Entity A "X"= 2, Entity B "X" can = 1 or =2


    Thanks!

  • Richard Napier
    Richard Napier EuropeMember Posts: 544 Bronze Trophy

    Hi There

    Yes. If the value on the B instance attribute "X" must match the "X" attribute in the A instance, you can use the same technique used to retrieve values from A into B as the Word rule to retrieve the location, just with a different attribute.

    If the B instance attribute "X" should be derived from the "X" attribute but not necessarily matching it you can achieve it in different ways.

    You could infer the value of the "X" attribute in "B" using the same technique, but let the user change it with a Value List in a drop-down if they wanted to.

    You could create a second filtered relationship control and show only certain instances of "A" when selecting the attribute "X" for "B" and so on based on whatever logic you can implement.

    Hope that helps

    R