non persistent entity and reference selector

Hello All,  I have a page like as shown below. I am getting state list by rest call , and after selecting the state again I want to call another rest service to fetch selected state’s districts state and district both are non persistent .  Currently i did below implementation .  In “State” drop down – selectable object is microflow , in which i am calling the rest call to get state list and On change of state drop down ,  i am calling another rest service to get district list  , i am getting districts but page is not showing those districts In “District” drop down : selectable obj is microflow , in which retrieving the districts of selected state.    Can somebody help me how district dropdown should get change based on selected states.        
2 answers

You can not do this with non persistable objects. You should create persistable objects and fill those with REST calls. You can then use the XPath datasource with constrained by function.





the issue here is that the datasource microflow of the district runs at opening of the page, at that moment the state is not yet selected and thus the list of districts is empty.


on-change of the State selection, run a microflow which refreshes the context object, which will retrigger the datasource microflow of the district.

Advice: add a decision on the datasource microflow of the state: if state is empty call rest service for state, else don’t. So the when you select a state, the state datasource will not run again unnecessary.  

The same can be done on the district datasource, when state is empty, don’t call district rest.