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

@AnveshKumar M  i believe after the change at the Catalog item for the name_of_user to Sys_id , the resultant SCTAsk form for u_requestor, it is showing blank 

 

chercm_0-1696893515272.png

chercm_1-1696893537985.png

chercm_2-1696893567020.png

 

@chercm Change your field type to Reference to sys_user instead of String type.

Thanks,
Anvesh

@AnveshKumar M  

getting error.

 

chercm_0-1696940243138.png

 

@AnveshKumar M  i recreated the field and reference to the sys_user table but still i am getting a blank field and i also tried to create a before business rule copy the variable to the field and it is still showing blank . need this field to be populated with the requestor name as the report need it 

 

chercm_0-1697028134924.png

chercm_1-1697028312923.png