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?

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.

2 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.

@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