Forum Stats

  • 3,768,987 Users
  • 2,252,890 Discussions
  • 7,874,826 Comments

Discussions

Connector Framework: How to structure a list in Load response and display the values in dropdown?

I'm trying to build an application in which -

1. A list of all the transaction IDs must be fetched from the database,

2. This list must be structured in Load response format in connector framework, and 

3. The list of transaction IDs should be displayed in a dropdown in OPA Interviews.

#1 mentioned above would be a simple fetch operation on a database table. I'm facing issues with #2 & 3

OPA Data Model: OPA data model is simple with only one entity - Global.

Questions:

1. How should this list be structured in Load operation response format?

2. How to convert this response into a value list, as value lists are necessary to display the values in a dropdown?


Thank you!

Tagged:

Best Answer

  • Snehal Tendulkar
    Snehal Tendulkar Member Posts: 39 Blue Ribbon
    Accepted Answer

    Hi Richard & Ian,

    Thanks for your help and suggestion for resolving this issue. This is what my solutioning looks like:

    At Load operation, 

    (i) Fetched only one record from DB with min(primary key); and

    (ii) Fetched all the primary keys, and concatenated this list delimited by comma making it a String attribute.

    Both these are sent as input to OPM at load.

    In OPM, I created a pseudo entity, that will hold the record fetched from DB along with the concatenated string attribute. This string attribute is then split into a list of Integer and displayed in a dropdown using JS. I used a combination approach (load and JS) as the fetch mechanism feature was not available on the version we were working on. And using the combination seemed like a better option than upgrading.

    Regards,

    Snehal

Answers

  • Richard Napier
    Richard Napier Member Posts: 301 Gold Badge

    Hi

    I may not be understanding completely, so forgive me if the following does not correspond to your situation. Here are two scenarios that I want to investigate because I am not sure to have the full picture.

    Scenario One

    1) The Load at the start of an Interview is returning some data from a database or application. Your Load to return multiple transactions from this source.

    2) You say that you only have the Global entity in your project. I believe this is the first issue. If your data is multiple transactions - then firstly you will need to adapt to this by having an entity to contain the instances of your transactions.

    3) You now want to display this list of transactions in a Drop-down for an attribute in Global. This can be done using an Input Extension in the JavaScript Extensions API which accesses the data in the entity and builds an options object for the drop-down to display (provided the data is in a child entity as described above, and the entity is loaded on the Screen or via the opm.extension.data.json file).

    We once did something similar in this article :https://intelligent-advisor.com/main/custom-options-dynamic-list-of-values/

    Scenario Two

    1) The transactions are not data, per se, but lists of values that you can pull from your data source - in which case your Connector can support this by using the <MetadataEnumerations> tag in your Getmetadata Response output. For example, the following (in a static example Connection)

    Allows the rule designer to leverage the lists of values at design time as well:

    I couldn't really work out which is your scenario, so I thought both might be useful.

    Please do get back to us with some more background.

    Snehal Tendulkar
  • Ian G Clough
    Ian G Clough Member Posts: 23 Red Ribbon

    One more option on Richards scenario One. Create an additional relationship between global and transaction (make sure it is to one transaction not many) called something like 'the selected transaction'. Now you can have a relationship input on the screen which can display the set of possible transactions as a list from which you can select one. You can then use a rule to infer a global attribute with the value of say the transaction id (or any other attribute from the selected transaction).

  • Richard Napier
    Richard Napier Member Posts: 301 Gold Badge
    edited Feb 12, 2021 4:17PM

    Good call Ian.

    I'm excited to find out exactly what the scenario is / what the data structure is!

  • Snehal Tendulkar
    Snehal Tendulkar Member Posts: 39 Blue Ribbon

    Richard & Ian,

    In general terms, yes the load operation shall return multiple rows as a response. I did think of creating a child entity, but it did not seem like a good design decision, because -

    1. The number of transactions/rows in the database table are expected to be in thousands. As of now, we have approx 2000 transactions/rows and these are expected to increase in the future. Therefore, creating thousands of entity instances may not be a good solution/design.

    2. Even if I decide to go with the above approach and create a child entity, I'm not sure how to convert the transaction IDs into a value list using purely OPA rules. One option, as Richard suggested, is to use Input Extension in JS Extension API (I will explore this option further).

    I was hoping to find a way to create a value list/enum in the connector code and assign it as a value to an attribute at Global (is this even possible?) - which will also reduce the size of the payload and avoid the need to create thousands of entity instances in OPA. I could create a MetadataEnumerations which will hold a list of all the transaction IDs. But, could this enumeration be used as a value list in OPA? Do note that the transaction IDs are not static and the length of this list will vary based on the number of transactions in the database table.

    Hope the above information provides better insights into the scenario.

  • Ian G Clough
    Ian G Clough Member Posts: 23 Red Ribbon

    Value lists / enums supplied as meta-data from the connector are essentially static hence probably not a good solution.

    If you have some criteria available to reduce the number of transaction to be selected you could look at dynamically loading data based on conditions defined in the rules see here:

    https://documentation.custhelp.com/euf/assets/devdocs/cloud20d/IntelligentAdvisor/en/Content/Guides/Policy_Modeling_User_Guide/Data_mapping/Load_data_during_interview.htm?Highlight=load

    You could also use a hybrid approach using a custom control extension as suggested by Richard and possibly the new(wish) Fetch mechanism to populate you selection list see here:

    https://documentation.custhelp.com/euf/assets/devdocs/cloud20d/IntelligentAdvisor/en/Content/Guides/Developer_Guide/Web_Interviews/Integration/Perform_web_service_calls_from_within_interview.htm?Highlight=fetch

    Then you could use dynamic data loading to load just the selected transaction(s) as sub-entities of global.

  • Ian G Clough
    Ian G Clough Member Posts: 23 Red Ribbon

    Value lists / enums supplied as meta-data from the connector are essentially static hence probably not a good solution.

    If you have some criteria available to reduce the number of transaction to be selected you could look at dynamically loading data based on conditions defined in the rules see here:

    https://documentation.custhelp.com/euf/assets/devdocs/cloud20d/IntelligentAdvisor/en/Content/Guides/Policy_Modeling_User_Guide/Data_mapping/Load_data_during_interview.htm?Highlight=load

    You could also use a hybrid approach using a custom control extension as suggested by Richard and possibly the new(wish) Fetch mechanism to populate you selection list see here:

    https://documentation.custhelp.com/euf/assets/devdocs/cloud20d/IntelligentAdvisor/en/Content/Guides/Developer_Guide/Web_Interviews/Integration/Perform_web_service_calls_from_within_interview.htm?Highlight=fetch

    Then you could use dynamic data loading to load just the selected transaction(s) as sub-entities of global.

    Snehal Tendulkar
  • Richard Napier
    Richard Napier Member Posts: 301 Gold Badge

    Hi Both

    Agree with Ian's remarks.

    Regarding Option A (Dynamic Load aka ExecuteQuery)

    The choice there might depend on what the connected application is and whether it requires effort on your part to add the dynamic load. B2B and B2C service as well as CX Sales support it out of the box, but if you are using Siebel then you will need to build the Workflow Processes and logic yourself. Not a great issue, but extra effort and testing, In all cases, the query that is executed would need to be fine tuned to ensure a decent wait time before the information is returned to the interview.

    Regarding Option B (interview.fetch()) and a Control Extension.

    Having experimented and done a few of these, this might work. The only dealbreaker is that fetch() is not supported on IE11 - if that is your case.

    The potential advantage from a user experience perspective is that here, the user (if we assume that this is a custom Search extension for example) can use "type ahead" and type the first few letters or numbers and the call will retrieve those matching records, rather than all 2000 of them. It may not correspond to your use case of course.

  • Snehal Tendulkar
    Snehal Tendulkar Member Posts: 39 Blue Ribbon

    Thank you Ian and Richard for your inputs.

    I will look into these options you provided and weigh them as per my requirements. I'm a bit more inclined towards the custom control extension option with the interview.fetch(). It'll ensure that I get a dropdown with a full list of transaction IDs.

    Thanks again! I will keep you posted on how I go about the solution.

  • Snehal Tendulkar
    Snehal Tendulkar Member Posts: 39 Blue Ribbon
    Accepted Answer

    Hi Richard & Ian,

    Thanks for your help and suggestion for resolving this issue. This is what my solutioning looks like:

    At Load operation, 

    (i) Fetched only one record from DB with min(primary key); and

    (ii) Fetched all the primary keys, and concatenated this list delimited by comma making it a String attribute.

    Both these are sent as input to OPM at load.

    In OPM, I created a pseudo entity, that will hold the record fetched from DB along with the concatenated string attribute. This string attribute is then split into a list of Integer and displayed in a dropdown using JS. I used a combination approach (load and JS) as the fetch mechanism feature was not available on the version we were working on. And using the combination seemed like a better option than upgrading.

    Regards,

    Snehal