Passing values from RITM MRVS to Change Request in a readable fashion
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
9 hours ago
I am trying to build a firewall rule change request catalog item. I have an MVRS that captures
- source_host
- source_ip
- destination_host
- destination_ip
- ports
- protocols
Once the RITM is approved, a Change Request is opened. Everything is working, except getting the actual details from the MRVS into the Change. The assignee has to go back to the RITM to find what to implement. I would like to populate the Implementation Plan on the Change with the contents of the MRVS in a readable fashion, but cannot find any recent, straight-forward explanations on how to do it. All the articles I found are much older than Yokohama and seem like they involve workarounds that I'm not convinced are still needed in more current releases, so I'm hoping someone can point me to something more recent that will step me through how to parse the json into something the engineer can follow, especially if there is more than one rule on a request. Thanks in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
8 hours ago - last edited 8 hours ago
Hi @EstherJ
Try with following method.
Script is sample code/not tested.
Method1 : Flow :If you are generating the Change Request via Flow Designer, add a Script action immediately after the Change is created:
var mrvs = fd_data.cat_item.variables.your_mrvs_internal_name;
var parser = JSON.parse(mrvs);
var details = '';
for (var i = 0; i < parser.length; i++) {
details += 'Rule ' + (i + 1) + ':\n';
details += 'Source Host: ' + parser[i].source_host + '\n';
details += 'Source IP: ' + parser[i].source_ip + '\n';
details += 'Destination Host: ' + parser[i].destination_host + '\n';
details += 'Destination IP: ' + parser[i].destination_ip + '\n';
details += 'Ports: ' + parser[i].ports + '\n';
details += 'Protocols: ' + parser[i].protocols + '\n\n';
}
var changeReqGR = new GlideRecord('change_request');
if (changeReqGR .get(fd_data.change_creation.change_sys_id))
{
changeReqGR .description = details;
changeReqGR .update();
}
Method 2: Advanced Script for Business Rules :If you are using a BR to open the Change Request automatically, add this script when initializing the Change:
var mrvsData = current.variables.your_mrvs_internal_name; // Replace with your MRVS variable name
var parsedData = JSON.parse(mrvsData);
var changeDesc = '';
for (var i = 0; i < parsedData.length; i++) {
changeDesc += 'Row ' + (i + 1) + ' Details:\n';
changeDesc += 'Source: ' + parsedData[i].source_host + ' (' + parsedData[i].source_ip + ')\n';
changeDesc += 'Destination: ' + parsedData[i].destination_host + ' (' + parsedData[i].destination_ip + ')\n';
changeDesc += 'Ports / Protocols: ' + parsedData[i].ports + ' / ' + parsedData[i].protocols + '\n\n';
}
var changeReqGR = new GlideRecord('change_request');
changeReqGR.initialize();
changeReqGR.short_description = 'Firewall Rule Change Request - ' + current.number;
changeReqGR.description = changeDesc;
changeReqGR.insert();
How to Use Multirow Variable Sets (MRVS) in Flow Designer
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti