Create RITMs from MRVS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Have a catalog item that has a MRVS that I need to parse out into individual RITMs via a workflow script. I can get it to create the other RITMs but they are blank and will not transfer any of the variable data over from the RITM. I know I'm close, but just not sure what the hang up is.
//Get MRVS and prepare to parse
var mrvs = current.variables.software_request;
var parseMrvs = JSON.parse(mrvs);
// Loop through the MRVS
for (var i = 0; i < parseMrvs.length; i++) {
//Create RITMS
var grReqItem = new GlideRecord('sc_req_item');
grReqItem.initialize();
grReqItem.cat_item = 'a7d66ee41b90ca10ce6f9683b24bcb4b'; // sys_id for Software Purchasing catalog item
grReqItem.request = current.request;
//Get the Next item from the MRVS
var multiVarset = parseMrvs.getRow(i);
//set variables
grReqItem.variables.new_or_existing = multiVarset.new_or_existing;
grReqItem.variables.epmo_reviewed = multiVarset.epmo_reviewed;
grReqItem.variables.operating_system = multiVarset.operating_system;
grReqItem.variables.choose_software = multiVarset.choose_software;
grReqItem.variables.found_software = multiVarset.found_software;
grReqItem.variables.product_name = multiVarset.product_name;
grReqItem.variables.publisher = multiVarset.publisher;
grReqItem.variables.version = multiVarset.version;
grReqItem.variables.edition = multiVarset.edition;
grReqItem.variables.product_sku = multiVarset.product_sku;
grReqItem.variables.license_type = multiVarset.license_type;
grReqItem.variables.license_metric = multiVarset.license_metric;
grReqItem.variables.free_stuff = multiVarset.free_stuff;
grReqItem.variables.contact_required = multiVarset.contact_required;
grReqItem.variables.current_rfp = multiVarset.current_rfp;
grReqItem.variables.number_of_licenses = multiVarset.number_of_licenses;
grReqItem.variables.unit_cost = multiVarset.unit_cost;
grReqItem.variables.tax_rate = multiVarset.tax_rate;
grReqItem.variables.total = multiVarset.total;
grReqItem.short_description = "Software Purchase for " + product_name;
// grReqItem.update();
grReqItem.insert();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
You are overcomplicating this.
Use the for each flow logic on the mrvs variable and use the out of box "submit catalog item request" action in flow designer and just drag and drop the variables.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
We don't use flow designer. Have never been able to get it to do even the most basic of things.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Don't think this is standard
var multiVarset = parseMrvs.getRow(i);Try
var mrvs = current.variables.software_request;
var parseMrvs = JSON.parse(mrvs);
parseMrvs[i].individual_variable_name;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
update this line
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
