Skip to main content

I am working in NAC forms and I would like to pull back data based on a previous field.

The example is, I choose an item in a drop down list (which is a data lookup to a SharePoint list.  The item is stationary order which has an associated cost to it in the SharePoint list, so if I choose laptop 1 (for example) I would like the cost field to pull back the cost from SharePoint for that item.

Can someone help please

Hi @Andy.Emery 

 

There probably a few ways of doing this, here is one way:
1. create an external data source with the columns you want to select (in your case it would be the laptop price). Add a condition to link the SharePoint column field to your data lookup control on your form:
 

  1. Add a form rule to show and set the value when the data control is selected (i used a label control in the screenshot below):

    You can probably also achieve this using 2 data lookup controls. 
    Note this wont show the data in the preview when designing the form, you will need to use workflow testing or run an instance


Hi thanks for your reply but I am sorry i am not following what you have done there?

I have added the external data source but i don't understand your condition or why/how you have added the variable for person group as shown above?

I cant see how you have linked the 2 fields to show the options

E.G. Supplier list is a data lookup field in my form which looks to my SharePoint list

I then have item list (in a repeating section) and I want to only bring back the items that are from the supplier chosen in the supplier field.

I will also then need to do cost and sku but once I get the first one sorted I can repeat the process

Sorry to be a pain


 Hi @Andy.Emery 

 

Data source variables are a means of returning array data for lookups.

 

In the example shown by @Prineel_V3 they are using Data lookup 1, (in your case this is the lookup dropdown for the stationary order) to filter the result of the data source, that then creates an object in the forms variables that can be used in rules to display items in the form, see below more detailed step by step.

 

In my example I have a lookup called Stock Items looking at my stock list in SharePoint.

 

Before we start you should make sure that in your data source you either have no columns selected to retrieve them all or if you have a lot of columns to make sure you select those you need.

 

 

Now we can add the lookup control to the form. 

 

In the config of the lookup I want it to show the item name which is stored in the Title column on SharePoint but store the id of the sharepoint item in the lookup so I can ensure a unique lookup.

 

Now to the form the value of this dropdown when selected will contain the ID, We can use this to filter the data source variable to get more data back.

 

Now we can have the lookup set up, we can create the data source variable. 

in my example I added a new DSV called ‘selected stock item’ and pointed it at the same connection used in my dropdown.

 

I want all of the fields to return so i leave the columns blank, I also set the limit to 1 as I know there should only ever be one item.

 

 

To ensure that the item returned is the one selected we need to add a filter condition, in my example I want to add that the ID = the value in my lookup field, however you will see this does not work.

 

 

The reason for this is because the value stored by Stock Items is a string, We need an integer for ID lookups to work, this is not always required as it entirely depends on the value you are looking up.

 

It is easy to work around however by creating a variable that converts Stock Items into an integer like so.

 

 

Now we can use Stock Item ID in the filter for the data source variable condition like so:

 

 

After saving this we have all of the data in the form but we need to show it somehow, An easy method will be to display the values in a label that un-hides when the dropdown is selected. 

 

When you go to select variables you will now see the new data source variable as a choice.

 

 

so we can create a label to show it.

 

 

However as items are not selected the control will error so we use a rule to hide it until it is filled

 

 

You can also create a rule to make it fill out some fields for you when the lookup is filled. 

 

 

Now selecting the dropdown fills the field with the value from SharePoint.

 

The best way to store data back to a workflow for use would be to enter the values into variables, this way you don’t need to create fields for everything on the form.

 

 

This is now visible in the workflow.

 

 

Hope this helps!

Jake


Hi @Andy.Emery 
Did Jake’s reply solve your question? 


Hi @MillaZ 

I ended up getting a technical person to help me as I was still struggling to do this

Thanks to all for your help


I have just been creating a new form with these types of data lookups and conditions in that was a bit more straight forward and the above instructions were great and helped me complete it on my own this time :)

Thanks @Jake for your detailed description it was a great help


Reply