How to fetch the RITM variables as part of catalog item order in ServiceNow

This script can be used in ServiceNow as part of the custom workflow attached to a catalog item to fetch values of user inputs in the form submitted as part of the catalog item order.

var utils = new x_moda_morpheus_ca.Utils();
// Querying the sc_req_item table in the workflow with current sys_id
var grItem = new GlideRecord('sc_req_item');
// After record mathcing storing the workflow inputs as array item in the variable name scratchpad
var scratchpad = {};
for (var item in workflow.inputs) {
utils.log("info", "input: item=" + item + ", value=" + workflow.inputs[item]);
scratchpad[item] = workflow.inputs[item];
// Checking for catalog attribute name "catalog_code" and printing the Attribute Label and display value in logs
// catalog_code is the attribute name in our catalog form
if(scratchpad[item].getLabel() != null && scratchpad[item].getLabel() == "catalog_code"){[item].getLabel());[item].getDisplayValue());
// If you want to print all the workflow inputs then uncomment lines 10 and 11