Update lookup field

  • 20 September 2016
  • 17 replies
  • 155 views

Userlevel 4
Badge +11

Hi,

 

sometimes here on the community someone ask how to set through a workflow a lookup field, so I've decided to write here how to do that..it's very simple! happy.png

 

In your workflow you need to know what is the ID of the elements in the list that's connected through the lookup column.. if your list has a lookup on the following list:

 

ID Title
1 Item1
2 Item2
3 Item3

and you want to set on your item a lookup to Item1, then in your workflow you have to set that field to the corresponding ID

 (Lookup is our lookup column)

but..what if you want to update a lookup column with multiple values?

Firstly, check that the lookup column allows multiple values..you have to explicit set it and sometimes simple things may be forgotten..

Then you have to create a string with all the IDs of the corrisponding elements, separated by ;#;#, so if in our case, we want to create a lookup to Item1 and Item3 we have to set the field as in the image

 

That's all..Easy, isn't it?

 

Giacomo


17 replies

Badge +1

Hi,

In my case, i want to update a lookup column with all items.I have the count of IDs, so i want to get not only Item1 and Item3 (1;#;#3 ) but get all items between the first and the last item(count).Is it possible??

Thanks

Userlevel 4
Badge +11

Hi,

in this case, you need to know all IDs, you can get them using a Query List action and store IDs in a collection variable, then you can use a collection operation to join all the values using ;#;# as delimiter, in this way you will get a string will all IDs separated by the delimiter you need in order to update the item.

Giacomo

Badge +1

Hi,

It works thank you.

Badge +1

But what variable type should I use to update the lookup field: Integer or Text?

Userlevel 4
Badge +11

Hi Anna,

if your lookup field should be set with just one option, you can use both, otherwise if you need to set several values, you have to use a text variable because of the # and ; characters

Badge +4

Hi Giacomo,

Thanks for the time saver & no-stress answer!  I had a hunch this was the case, then also got prompted for a numeric when selecting the Set & Value - it was terrific to know the hunch was right & I didn't need to waste any time figuring out more.

Badge

Hi,

The lookup value is correctly set with this method (go on list view to see the changes). But when I try to get the value from the active workflow, the lookup value is Empty.

Even with Commit pending changes, the lookup value is still empty on the workflow.

You need to execute a new workflow, in order to see the lookup value correctly set on this new workflow.

Do you have the same issue?

Thank you for your help.

Badge +3

Giacomo Gelosi‌, 

I have another senaio  with small change, I want to copy the list item to same list with title change, In my List I have an lookup field (which is referred to another list in same web site) On start of workflow i am able to copy data into variable and able to create a new item, but when i am trying to assign value to Lookup field its failing. can you suggest me here how can i resolve this issue? i am trying as in below image

Thanks and Regards,

Kotresh

Userlevel 4
Badge +11

Hi Kotresh,

unfortunately I currently haven't tested it on O365 so I'm not sure if the syntax I suggested in the post are valid also there..

if yes, probably you have to modify how current item field value is stored..have you tried logging current item "origin" field value and check if it's the same as in my post..otherwise, could you try putting some fixed value to verify the syntax required on O365 and then modify current item value to respect the syntax you've found..

please, if a different syntax is required in O365, write it back here so I can update my post..

thanks

Giacomo

Badge +3

Hi Giacomo, 

Thanks for your quick reply, 

Yes, I Logged the current item value it is returning as "{"results":[{"Id":7,"Value":"CCTV"},{"Id":1,"Value":"Email"}]" . I tried to put same as hard coded values . but not luck. 

May i know will it support in O365 environment ?

Thanks and Regards,

Kotresh

Userlevel 4
Badge +11

Could you tried with fixed values like in my post with just IDs and ;# separators, without all the structure you’ve logged?

Badge +3

Hi , 

I have tried by providing the values like as below,

1;#;#7

;#1;#7

{"Id":7,"Value":"CCTV"}

1

Email

;#Email

Kindly let me know if there is any other ways where i can resolve this ASAP.

 

Again Thanks for your quick response.

Regards,

Kotresh

Badge

Hi Giacomo Gelosi,

Do you have the same issue when you try to get the lookup value on your workflow after the actions mentioned on your post?

Thank you for your feedback.

Userlevel 4
Badge +11

Hi,

sorry, I've lost the first notification of your question..honestly I have no more the test case workflow I've built when I've created the post so I'm not able to check it..sorry!

Userlevel 4
Badge +11

Hi, I've would test 1st, 2nd and 4th option but as you say this is not valid, I'm currently not aware of other method..maybe others here on the forum have a solution for this problem..

Giacomo

Badge

I will try to open a case to Nintex support. Thx for your feedback!

Badge +3

hi , 

I have created support ticket for this issue. 

Reply