- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2024 04:36 AM
Hi team,
I have the list of business rules on DEV and PROD with incident and task table. PROD environment has 7 more business rules and I need to find out which of them are missing in DEV. To be 100% sure I would like to compare with sys_id.
Could you please advise how I could retrieve sys_id for every single business rule on the list so I can compare them in excel then?
Thank you,
Martin
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2024 04:45 AM
Hi,
Create a new record as below-
https://your_instance.service-now.com/sys_ui_list.do?sys_id=6176a532d700310066f70eca5e61039f
Result:
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2024 05:11 AM
Hi @Martin45
If you want to fetch the Business Rule via script, you can use below logic :
var Headers = ["Name","Table","Description"];
var fileName = 'BusinessRules.csv';
var csvData = '';
for (var i = 0; i < Headers.length; i++) {
csvData = csvData + '"' + Headers[i] + '"' + ',';
}
csvData = csvData+"\r\n";
var gr = new GlideRecord('sys_script');
gr.addActiveQuery();
gr.query();
while(gr.next()){
csvData = csvData + '"' + gr.name + '",' + '"' + gr.collection+ '",' + '"' + gr.description+'"';
csvData = csvData+"\r\n";
}
var grRec = new GlideRecord("incident");
grRec.addQuery("sys_id","sys_id of a test incident record");
grRec.query();
if(grRec.next()){
var grAttachment = new GlideSysAttachment();
grAttachment.write(grRec,fileName, 'application/csv',csvData);
}
This will generate a csv file on the test incident provided as an input and you can download that to proceed. Also, if you want more columns to be added, that could be done by tweaking the csv headers and the data fetch logic.
Thanks & Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2024 04:45 AM
Hi,
Create a new record as below-
https://your_instance.service-now.com/sys_ui_list.do?sys_id=6176a532d700310066f70eca5e61039f
Result:
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2024 05:11 AM
Hi @Martin45
If you want to fetch the Business Rule via script, you can use below logic :
var Headers = ["Name","Table","Description"];
var fileName = 'BusinessRules.csv';
var csvData = '';
for (var i = 0; i < Headers.length; i++) {
csvData = csvData + '"' + Headers[i] + '"' + ',';
}
csvData = csvData+"\r\n";
var gr = new GlideRecord('sys_script');
gr.addActiveQuery();
gr.query();
while(gr.next()){
csvData = csvData + '"' + gr.name + '",' + '"' + gr.collection+ '",' + '"' + gr.description+'"';
csvData = csvData+"\r\n";
}
var grRec = new GlideRecord("incident");
grRec.addQuery("sys_id","sys_id of a test incident record");
grRec.query();
if(grRec.next()){
var grAttachment = new GlideSysAttachment();
grAttachment.write(grRec,fileName, 'application/csv',csvData);
}
This will generate a csv file on the test incident provided as an input and you can download that to proceed. Also, if you want more columns to be added, that could be done by tweaking the csv headers and the data fetch logic.
Thanks & Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.