Trigger approval for a user selected in User variable on catalog item

Rekha20
Tera Contributor

Hi All,

I have a variable called u_user on catalog form referring to sys_user table.

I wanted to trigger approval for the user selected in this variable. Please let me know how to achieve this?

 

I used below scrip in approval user activity in worklfow:

 

var answer = [];
answer.push(current.variables.u_user);

 

But not triggering. Please help me.

 

Thanks,

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Rekha20 

should be easy one provided user has email, user is active and not locked out

var answer = [];
answer.push(current.variables.u_user+'');

 

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

View solution in original post

4 REPLIES 4

Lakshmiprasann7
Tera Contributor

Hi ,

 

You can achieve through workflow,drag user approval activity write the code as below.

 

var answer = [];

answer.push(current.variables.u_user.toString());

Lakshmiprasann7
Tera Contributor

Please mark the answer if it is helpful

Gunjan Kiratkar
Kilo Patron
Kilo Patron

Hi @Rekha20 ,

That variable is reference field then that variable must have user sys_id. So that above statement should work. But you can try below debugging for workflow:-

 

1. Check the Workflow Context: Ensure that the u_user variable is set and contains a valid sys_id before the approval user activity is executed.

 
2. Permission Issues: The user specified in the u_user variable might not have the necessary permissions to approve the item in question. e.g. approver_user role
 
3. Debugging: You can try adding some debug statements to the script to see if the answer array is being populated as expected, for example:
 
var answer = [];
answer.push(current.variables.u_user);
gs.info("Answer: " + answer);

Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

Ankur Bawiskar
Tera Patron
Tera Patron

@Rekha20 

should be easy one provided user has email, user is active and not locked out

var answer = [];
answer.push(current.variables.u_user+'');

 

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