Chaining Reference Selectors Where Data Comes From REST API Requests

0
I have 3 reference selectors. All of them have their data source as Microflow under ‘Selectable objects’, and these microflows call REST APIs to get the data which is returned as a list of the entity.   The reference selectors are all contained within a data view of a non-persistable entity on the page. This non-persistable entity has many-to-one associations to each entity that are used in the reference selectors.   The value chosen for a reference selector affects the data in the next reference selector. For example, the ID selected in referenceSelector1 is used in the microflow which gets the data for referenceSelector2. Because of this, all of the reference selectors have an ‘On change’ event which clears the values for all the following reference selectors (commit no, refresh in client yes).   The issue I’m having is as follows. Imagine the on change event is triggered for referenceSelector2. Because this change to the data view’s entity is refreshed in client, it causes the reference selector’s data source microflows to be re-triggered. This is what we want for referenceSelector3, as it uses the new value of referenceSelector2 to get new data. However the data source for referenceSelector2 is also refreshed, which results in the selected value being cleared. I don’t want to refresh the data source for referenceSelector2 here, however it seems to happen automatically whenever the data view’s entity is refreshed in client.   (Image shows referenceSelector3 has been populated using value of referenceSelector2, but referenceSelector2 has now cleared and will keep clearing if I try to reset it.)  
asked
2 answers
0

Hey Adam!

 

I’ve done something like this before, and I understand how the initial implementation can be kind of frustrating. What I ended up doing, to mitigate the execution of the data source microflow, was have a decision at the beginning of the data source microflow that checked if the association was already populated.

 

If it was, I wouldn’t call out to the REST api, otherwise I’d call out to retrieve the list of selectable values.

 

Hope this helps. Please let me know if you want some more help with this or if something isn’t clear.

Best of luck,
Austin

answered
0

I managed to achieve this using entirely non-persistable entities. For each dropdown, I created a new many-to-many association to store the current data source for that dropdown. Then when the microflows were triggered to get the new data sources, I checked if the current data source and new data source had the exact same IDs, and if they did, I returned the current data source from the association, meaning that the value the dropdown had was no longer being wiped out.

answered