i have a different user name in the ritm request for requested for field

chercm
Mega Sage

i followed the article : https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0852249

 

1. Add a new custom 'Requested For' [u_requested_for] field to the 'sc_req_item' table.
2. Add a variable['requested_for'] at the item level to capture the user for whom this item is requested.
3. Create a Before insert business rule on 'sc_req_item' table to copy the value of variable ['requested_for'] to the sc_req_item.u_requested_for field using code that looks like below:
current.u_requested_for = current.variables.requested_for; // Copy the variable value to the RITM's Requested For field

 

from my flow designer , i have a variable name_of_user in the stashbucket, how can i use it to update the requested for field on the Request item form?

 

chercm_0-1696725225465.png

 

1 ACCEPTED SOLUTION

@chercm try changing the before insert business rule to after Insert business rule and change the code to below one.

 

Create a new before insert Business rule on table sc_req_item and add the following script.

 

 

 

(function executeRule(current, previous){

 

var gr = new GlideRecord('sc_request');

 

if(gr.get(current.request)){

 

gr.requested_for = current.variables.name_of_user;

 

gr.update();

}

 

})(current, previous)

Thanks,
Anvesh

View solution in original post

15 REPLIES 15

@chercm if you are allowing the name of user to be picked from sys_user table that would be great, but make sure the type of the variable is reference type. If it is select box or look up select box type, in your variable configuration select the value field to be sys_id and label field to name.

Thanks,
Anvesh