Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

Map Catalog Variables to Change Request

Dillin  Bradley
Tera Expert

Hello,

 

Looking for some help. I have a catalog item that creates multiple SC tasks and after they are all complete the workflow creates a Change Request. How can I map the variables from the RITM to show in the change request? Or at least populate them into the Change Request description field?

 

Thanks,

Dillin

1 ACCEPTED SOLUTION

Dillin  Bradley
Tera Expert

I was actually able to more easily solve this. In flow designer I was able to query the RITM and variables form that and add them to the description field.

 

View solution in original post

4 REPLIES 4

Rajesh Chopade1
Mega Sage

Hi @Dillin Bradley 

 

Create a Script in the Workflow: Add a script in the workflow just before the creation of the Change Request. This script will read the variables from the RITM and store them in a way that the Change Request can use.

 

// Get the RITM record
var ritmGr = new GlideRecord('sc_req_item');
ritmGr.get(current.sys_id);

// Initialize an empty string to store the description
var description = '';

// List of variables to include in the Change Request
var variables = ['variable1', 'variable2', 'variable3']; // Replace with your variable names

// Loop through each variable and append to description
for (var i = 0; i < variables.length; i++) {
    var variableName = variables[i];
    var variableValue = ritmGr[variableName];
    if (variableValue) {
        description += variableName + ': ' + variableValue + '\n';
    }
}

// Store the description in the workflow scratchpad
workflow.scratchpad.change_description = description;

 

 

Update the Change Request Creation Script: Modify the script that creates the Change Request to use the workflow.scratchpad.change_description value:

 

// Create the Change Request record
var changeGr = new GlideRecord('change_request');
changeGr.initialize();
changeGr.short_description = 'Change Request from RITM ' + current.number;
changeGr.description = workflow.scratchpad.change_description;
// Set other fields as needed
changeGr.insert();

 

 

i hope my answer helps you to resolve your issue, if yes mark my answer helpful and correct.

THANK YOU

rajesh chopade

Ankur Bawiskar
Tera Patron

@Dillin Bradley 

how are you creating the CHG? are you using flow or workflow?

which variables from RITM should be mapped with which fields of CHG?

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

Hi Ankur,

 

I am creating the Change Request from the Catalog Item Workflow. I want the variables jut to populate into the Description of the Change or even just show as variables on the form if possible.

Dillin  Bradley
Tera Expert

I was actually able to more easily solve this. In flow designer I was able to query the RITM and variables form that and add them to the description field.