Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Hi Team,  In service operation Workspace under interaction record we have UI actions which is Create

AA6
Tera Contributor

Hi Team,  In service operation Workspace under interaction record we have UI actions which is Create Request , Create Incident, whenever click Create Request it will show  interaction record  agent name need to Auto populate  in the catalog  form Requested for field level?

AA6_0-1764154682665.png

 

7 REPLIES 7

soumyadeep10
Giga Guru

Correct me if I'm wrong, do you mean that after you click on the Create Request button, the catalog form will open up and there you will find the 'requested for' field pre-filled with the agent name ?

AA6
Tera Contributor

Hi @soumyadeep10 

Thank you for your reply

yes , whenever click on the Create Request button, the catalog item selecting after that form will open then in the catalog form level 'requested for' field here need to auto populate agent name ?

Hello @AA6 ,

 

Here's how you can achieve it. 

1. You need to go to the UI Action 'Create Request'. In the script section, at the end add this script:

var agent = current.assigned_to; //if there is any other field which stores agent name, replace assigned_to with it
var url = 
'https://' + gs.getProperty('instance_name') + '.service-now.com/sp?id=sc_cat_item&sys_id=<sys id of the catalog item>&sysparm_requested_for=' + agent;
action.setRedirectURL(url);

 2. Create a catalog client script for the catalog item:

//Logic to set value from the url
var gUrl = top.location.href; //get the URL
//fetch the parameter
var setReq = new URLSearchParams(gUrl).get("sysparm_requested_for");
g_form.setValue('requested_for', setReq);

[Note: make sure to add the catalog item sys id and change field names if required.]

 

This solution should work. Please let me know if it works or not and if it does, please mark my response helpful and accept the solution. Thank you


*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

@soumyadeep10 

this is not going to work as the OOTB UI action is different

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