Populate Dropdown field

I have created a data variable for Customers that might be useful loading the dropdown field of the customer in the sales order as you see the image below. I tried to figure it out from the documentation but have hard times.

Can anyone help?

1 Like

I spent about 4 hours figuring this out and its easy once you get one working. In my case, I have 2 tables:

  1. A list of items - one column in the table is for item category
  2. The category table has a list of item categories

Add the following in the dropdown properties section:

  1. In the Option List, I wanted to see the list of possible categories I could assign my asset to I used:
    MAP(data.category, {label: item.fields.Name, value: item.id})

  2. I also wanted to populate the existing category when the page is loaded. So, for Selected Value I used:
    data.Assets.fields.Category[0]

  1. You also need to configure a page variable for the selected value… so you can save the dropdown selection to the record

I hope that helps.

5 Likes

Thank you so much Jeff for your step by step suggestions. I just have done the first step, I can see customers in the dropdown list. I shall do the rest soon.

Hi again
Now I am trying to populate existing customer when the page is loaded as you described in #2.
Here is the data resources I have:

CustomerProfile is an Object in Sales Order. Therefore, I have created SalesOrder Data resource as follows:


Is this the right approach? I was expecting if there is any way we can just link CustomerProfile (association) with SalesOrder

However, when I go to set the “selected value” through formula, i don’t see the properties of salesOrder i.e. Customer profile. I’m sure I am missing something here as I see it’s working for you with the Category. Thanks for your help again.

The formula editor most likely thinks that your SalesOrder is a collection of items, and thus does not suggest you to access its properties like that. You can change it to a “single data record” through the variables menu. (only do so if it truly is a single data record).
image

Hi
You’re right, when i turned that to single date record I see those properties.
My sales order screen contains both collection of sales order and editing data sources. I guess I can have both in data variable in the same screen. I shall give a try

If it’s a collection of sales orders, do not configure the data variable as single data record as it’s obviously not.

Use logic to pick out the specific saleOrder from the collection for editing, using formulas you can find help for example in FIND, FIND_BY_KEY, PICK_ITEM formulas

Hi thanks. I think that’s a better approach. In that case, how I know which items in the collection of sales order has been selected for edit? Would suggest by an example? Btw, I want to show the collection of sales order in a table but didn’t find any,

If your collection is for example in a repeated component, in the specific items logic canvas’ tap or change events should have propagated the context of the repeated item. By default it’s under current object, but if you’ve changed the “repeat as” property it can be found under repeated property.

So this means that for example you can do stuff like FIND_BY_KEY(saleOrders, id, current.id) to get the item you want to update. So current.id will be the id of the object you clicked on the repeated array.

Great! Thank you so much for your help.

2 Likes

Hi! Thanks to this thread I have two dropdowns working.

Question:
I have 2 data resources (kids, actions) and those are the dropdowns. I need to save those plus number input to 3rd data source (bank). So I want to save

  • who did (Dropdown 1, from data source “Kids”)
  • what did (dropdown 2, from data source “actions”)
  • and how many times (Input field, onlu numbers)

I list that saved info (who, what, how many times) on another page. Can I save those all using save button straight to “bank” or do I need to save them first as page variable and use the save button to send those from page variable to data variable?

@Harri_Valijarvi a good architectural pattern would be to save the picked value of each dropdown/input into a separate page variables like pickedKid, pickedAction etc – or if they map directly to a data variable, you can bind the value to data.NewBankRecord.kid.

Then, in the Create record node, you simply pick the data into the create payload from wherever in variables it was stored.

1 Like

@Harri_Sarsa I tried to map them directly to data variable but all I got was empty line. Most likely I didn’t do everything correctly, maybe that Create record part wasn’t right. I will try again (and again and again :grinning:) and post screenshosts if I can’t get it work. Thanks!

1 Like

Nope. I can’t get it working. Dropdowns work as they should but selections wont get saved. Only empty rows.

Data resource

Data variables

Dropdown 1
Option list MAP(data.childs,{label: item.name, value:item.name})

Dropdown 2
Option list MAP(data.addCarrots, {label: item.name, value: item.name})
Selected value MAP(data.addCarrots, {label: item.name, value: item.name})

save button

I deleted “count” input field trying to simplify thigs a bit.

What is wrong?

1 Like

It looks to me your issue is with the Selected value field.

You have the right idea in the first dropdown, but using a formula breaks the two-way binding. So your selection does not actually propagate to data.NewDeposit.who. If you set the binding type to Data variable value it looks like it should work correctly.

image

The formula can ad hoc evaluate and transform data for you, but you cannot store data in a formula – if that makes any sense.

Yes, I understand. It worked! Thank you @Pekka_Aaltonen! I had to recreate the site that lists saved values but after that it worked.

1 Like

Hello, guys! The instructions here were very helpful and I got to populate my dropdown with a list-of-objects pagevariable using the MAP function in options list. The problem is that, testing this on a device, after the user taps the dropdown and chooses one item, it doesn’t save the selection and the options list DISAPPEARS if the user taps it again, as if there were none, and shows only the placeholder! I am afraid this is a nasty bug :frowning:

Aside from using the MAP function in the list options (which works to show the options list only the first time the user taps it), I also used PICK_ITEM to populate the dropdown label, which worked fine and shouldn’t interfere, as shown in the print. There are no event nodes triggering. I even left the dropdown unbound to test but the same behavior persisted.

PICK_ITEM(pageVars.TextStat, NUMBER(appVars.Language))

MAP(SELECT(pageVars.TextStatVar, item.Lang == appVars.Language), {label: item.Label, value: item.Value})



Please help!

Trying to work around this by setting pagevar to the filtered values and labels, it says the page variable, even being a list of objects with the same two properties, is not assignable to the options list of the dropdown :cry:

Since the options I want to show are of a fixed number, I also tried assigning pick_item on the labels in options list, but to no avail. The list shows up empty. The only workaround currently functional to me is assigning all input fields to app variables and triggering a replace-page action so that the dropdown is always accessible to the user (always as if for the first time, since the first time is the only time it works). The other option would be to set the dropdown to invisible after input and some other field visible but if the user needed to change the selection s/he would probably need to re-load the page anyway. Help would be appreciated!

I think what you’re seeing is the same thing a number of us have seen. It’s been reported as a bug. You can read more about it in other recent threads about the Drop-down.