I have to assign user in assigned to field based on field value in catalog item.

niveditakumari
Mega Sage

Hi, 

 

I have to assign user in assigned to field based on field value in catalog item. I have catalog item and in that there is variable called 'ABC' that is a select box field and it is having values 1, 2, 3, 4, 5, 6 and when user submit request for that it generate 4 catalog task one after closing another task. First task assigned to 'L1 group', Second task assigned to 'L2 group', Third task assigned to 'L3 group' and Fourth task assigned to 'L4 group'. 

 

When user submitting request and user select '1' value in ABC field then it should assign First Task to 'Nora', if user select '2' in ABC field then it should assign First Task to 'Neemat'. 

When user submitting request and user select '2' value in ABC field then it should assign Second Task to 'Digambar', if user select '2' in ABC field then it should assign First Task to 'Sahabas'. 

It is assigning based on field value selection in 'ABC' when user submit request and assigned to user in task. 

I'm using flow for that. 

niveditakumari_0-1744973554045.png 

 

niveditakumari_1-1744973625865.png

 

 

Do I need to write script to assign user in assigned to script. 

Can anyone please help me with that. 

 

Regards, 

Nivedita 

 

 

4 REPLIES 4

Voona Rohila
Kilo Patron
Kilo Patron

Hi @niveditakumari 
Yes, You need to write a Inline script for Assigned to Mapping

var res = fd_data._1__get_catalog_variables.confirm; //use proper variable name here.
if(res == 'A')
return 'sys_id_of_user'; //Store user sys_id in property and get it here.
else if(res == 'B')
return 'sys_id_of_user';//Store user sys_id in property and get it here.

VoonaRohila_0-1744976347989.png

 

https://www.servicenow.com/docs/bundle/yokohama-build-workflows/page/administer/flow-designer/concep...

 


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

Ankur Bawiskar
Tera Patron
Tera Patron

@niveditakumari 

You can use flow variable of type string and use "Set Flow Variable" flow logic to set that with the user sysId

Then use this flow variable and it will be populated in the Assigned To field

Something like this in flow variable

var val = fd_data._1__get_catalog_variables.selectBoxVariableName; //use proper variable name here.
if(val == '1')
return 'user1SysId'; 
else if(val == '2')
return 'user2SysId';

AnkurBawiskar_0-1744978017728.png

 

AnkurBawiskar_1-1744978041215.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@niveditakumari 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Robert H
Mega Sage

Hello @niveditakumari ,

 

I would recommend not to hard code the approvers in the Flow script. With 6 options and 4 tasks you would have 24 different combinations and 24 sys_ids to hard code. That is not a maintainable solution.

 

Keep the assignment logic outside of the Flow and use "Assignment rules" instead.

Here is an example that I tested successfully on my end:

 

  1. In the Flow, just create the Catalog Tasks and give each one a unique Short description. Don't assign them to groups or users here.

  2. Create an Assignment Rule, like this:
    RobertH_0-1744984929669.png

    If you do not see the "Variables" option please select "Show related fields" and then open the choice list again.

    RobertH_1-1744984997075.png

     



  3. Create the remaining Assignment Rules in the same fashion:
    RobertH_2-1744985084462.png

     

 

You will end up with a rule set that is easy to review and maintain.

 

Here is the result showing an example request where I selected option 2:

RobertH_3-1744985179109.png

 

Regards,

Robert