How to auto populate / get variables from Catalog item to Catalog task

abdullahkhan852
Tera Contributor

abdullahkhan852_1-1726541644475.png

Hello @Mark Roethof @Ankur Bawiskar @Ravi Gaurav @Lola B 
This is a requirement for service catalog
I want to Auto populate the task form based on the data that user has filled in the request from.
Above mentioned is the request form .
And here below this is how a Cat Task from should look

abdullahkhan852_2-1726541926276.png

How can i achieve this?
The data that has filled in request from should be auto populated in the task 
and there are some more fields to be added
How can i achieve this ?
Its a urgent requirement!!!

2 REPLIES 2

Ravi Gaurav
Giga Sage
Giga Sage

Hi @abdullahkhan852 

You can create a Record producer directly on Task table.

Or 
You can create a Business Rule that triggers when a Catalog Task is created. This Business Rule will pull data from the Request Item (RITM) and populate the corresponding Catalog Task fields.

(function executeRule(current, previous /*null when async*/) {
var ritm = new GlideRecord('sc_req_item');
ritm.get(current.request_item); // Getting the RITM associated with the task

if (ritm.isValidRecord()) {
// Example of copying data from RITM variables to task fields
current.short_description = ritm.variables.short_description;
current.description = ritm.variables.description;

// Add more mappings for custom fields and additional variables
current.u_custom_field = ritm.variables.u_custom_variable; // Example for custom field
}
})(current, previous);

--------------------------------------------------------------------------------------------------------------------------


If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!

Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI

 YouTube: https://www.youtube.com/@learnservicenowwithravi
 LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/

sunilsargam
Tera Guru

Hi @abdullahkhan852 ,

 

This requirement can be achieved by 2 ways.

1. you create record producer on same table with required fields.

OR

2. Create a script on submit of your request, which will eventually take the values submitted and will populate in task table. (Workflow / flow / BR ).