I’m going around in circles trying to do something that ought to be simple (I think). Can anyone help with this challenge.
I need to populate one list using the contents of another where they have a common field. I have set up a simple example to explain here:
Imagine a multidropdown where the user can select multiple Fruits
where the Fruits are an Option Set
Then I have an RG that uses a Custom State called current_fruit_details of type Fruit Details as it’s Data Source where Fruit Details is a dB Table
and that RG displays the Fruit Display’s name in each cell and allows the user to type in a cost.
The db Table is
The user is entering a new record and I need to avoid writing anything to dB until all data entry is completed and they press [Save]. So writing to the dB or having dummy template records on the dB is not an option. As you know, this is good practice to avoid orphan records.
My first dilemma is that I need to populate the custom state current_fruit_details with the fruits selected in the multidropdown. How do I do that as the lists are of different types they just have a common filed ‘Fruit’
The second problem is that I can’t just clear the custom state every time the multdropdown changes because I need to retain the cost values the user has input for the fruits that are still selected. I imagine I will have to use a ‘filtered’ on the current_fruit_details to remove items and then an merge to add the new ones… but again the lists are different types.
So the challenge is to find a way to do this without writing to dB. Any takers?
Good questions, I can offer some insight into one of them. Your RG can have a Condition (or if you don’t need to start by displaying all fruit, you could just have it as your default data source) on it that when the multidropdown selection is “not empty” the RG data source is “search for” “fruit database” and the Constraint in the “search for” function is = to the Multilinedropdown value.
Do a search for fruit details with constraint fruit is in the list of selected fruit
You can, you just might need to reimagine how to keep track of the costs. Use the when input value is changed trigger and select the multidropdown element and then action is to set the custom state list and value is ‘this multidropdowns value’.
How are you tracking the costs entered by the user?
Thanks @customersupport but the Fruit is not in the dB. Eventually when the user presses [Save] I will save to the dB so Do a search approach will not work in this case.
The fruit list is in an Option Set and the Multidropdown (pointing to Option Set) starts empty and the user selects which fruits they want. Then below that the RG should display the selected fruits and allow the user to add the cost beside each. At this stage the only point of the dB is that it provides the Type for the RG.
I was looking at using a custom state and pointing the RG to that so the costs are stored there @boston85719 , but I still can’t find how to associate a cost with a fruit. I think I am almost seeing it but not quite.
Not sure what “tracking the costs…” means, please ask another way. The aim is to build a list, either the RG or a custom state list that has the fruit + cost items that can be saved to the dB when the time is right.
Thanks for taking the time to chip in.
Just made the editor for the test case publc:
“Search for” works on option sets as well as db. You should be able to do the constraints in search for on an option set.
Good to know. I’ll give that a shot tomorrow. Thank you @customersupport
1 Like
Got a chance to sit down and take a look just now @customersupport - when you say “Search for” I think you were referring to “Get an option” and I know about that. I can’t see how it can help with getting my lists merged however, filtered no problem but merged no way. Reached the conclusion I need to build a custom element instead of using the multi-select dropdown and RG. I had hoped there would be an easier way with existing elements but there does not appear to be. It’s already had two or three days focus so it’s time to dump the get the designer to give me another design. Thanks for your help.
There is.
So Fruit is IN the Database, as an option set
Type would be the Option set that is the list of fruits that IS in the database as an option set
Put into the RG and input, so in one cell will show the name of fruit as text and the input element set to number
Your multidropdown will be of type fruit (ie: your option set that you have in the database that is a list of fruit). When a user clicks onto and makes the selections, this creates a ‘selected list’ for the multidropdown as exposed as ‘this multidropdowns value’…so your RG to show the selected fruit is of type fruit (ie: the option set you have in your database that is a list of fruit) and the datasource is multidropdowns value.
That is how you get the list of selected fruit into the RG from the multidropdown.
All other things should be approached as if it is a shopping cart, there are various threads and tutorials that cover that.
Thank you @boston85719 - this sounds interesting. I can’t wait to try it. Once I get over getting the fruits into the RG I home and dry - the rest I can do. Many thanks. Let me study and play with this.
Sorry @boston85719 I went into my Fruit example (editor link pasted above) and I have everything as you say AS FAR AS I CAN UNDERSTAND. But still have the two issues,
-
If users selects three or more fruits in thee multidropdown then clicks to delete one in the multidropdown after having entered values in the RG, the fruits that come after the deleted one appear to lose the prices that had been entered for them. Although if I reselect the deleted fruit again in the multidropdown the cost that had gone blank returns.
-
When I save (ignore my bad practice two custom workflows calling each other this is just a quick test to see if this can be made work) then the fruits are saved but not the costs.
So costs are just not associated. Perhaps I am misreading/misunderstanding something you are saying but I’ve poured over the Option Set and Option Set in DB multiple times and I can’t fathom what it is I am not seeing.
Hope you have a minute to take a look.
I solved this when I made the custom_state a List of Texts and the texts are added using
custom_state list:plus item Fruit value’s Display:find & replace
where Find is Fruit value’s Display
and Replace By is Fruit value’s Display|Input cost’s value:formatted as 1028.58
And it is removing uses the reverse (:minus item) also with :find & replace
Very easy to do once I dropped the Type = Option Set or DB and just went with text.
Thanks guys. We got there in the end.
1 Like