how to pass the mrvs multirow data set value in work note
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2024 11:26 AM
- Hi Team I want to pass the data from multirow variables set(mrvs) to work note I am having 5 variables in mrvs.
- 1.applications 2.business_application_bai 3.SCA 4.SAST 5. VERSION. note these all are list collector type
- here variable 1 and 2 is having parent child relationship the data is coming from cmdb_rel_ci.
- Basically I want to write a script to check the application variable is having business_application_bai to connected to it or not and the I want to check which SCA is connected to business_application_bai and then which version is connected to which SCA.
- BETTER example-- I will select multiple application then multiple business_application_bai and the same for sca and version. But I want to print the unique combination of it in work note that which one is related to which one. note like every possible combination..
- As of now My script providing every possible combination which possible. but I want unique combination which is related one like this
- Application1-BusinessApplication1 Application2-BusinessApplication3 Application3-BusinessApplication4 Application4 Application5-BusinessApplication6
- var array1 = [];
- var array2 = [];
- var array3 = [];
- var array4 = [];
- var array5 = [];
- var array6 = [];
- var array7 = [];
- var appl = current.variables.application_information;
- var totalRows = appl.getRowCount();
- for (var i = 0; i < totalRows; i++) {
- var applications = appl.getRow(i).getCell('applications').getCellDisplayValue();
- var bai = appl.getRow(i).getCell('business_application_bai').getCellDisplayValue(); // BAI
- var name1 = appl.getRow(i).getCell('name').getCellDisplayValue();
- var name2 = appl.getRow(i).getCell('names').getCellDisplayValue(); // Added name2
- var version = appl.getRow(i).getCell('application_version').getCellDisplayValue();
- gs.log("Row " + i + ": applications=" + applications + ", name1=" + name1 + ", name2=" + name2 + ", version=" + version);
- array1 = name1.replace(/\s*\,\s*/g, ",").trim().split(',');
- array2 = name2.replace(/\s*\,\s*/g, ",").trim().split(','); // Added array2
- array3 = version.replace(/\s*\,\s*/g, ",").trim().split(",");
- array4 = applications.replace(/\s*\,\s*/g, ",").trim().split(',');
- array5 = bai.replace(/\s*\,\s*/g, ",").trim().split(','); // Added for business_application_bai
- }
- var workNotes = '';
- for (var i = 0; i < array4.length; i++) {
- var application = array4[i];
- var baiList = [];
- for (var j = 0; j < array5.length; j++) {
- var baiItem = array5[j];
- var grRel = new GlideRecord('cmdb_rel_ci');
- grRel.addEncodedQuery("child.sys_class_name=u_cmdb_busapp_instance^parent.sys_class_name=cmdb_ci_business_app");
- grRel.addQuery('parent', application);
- grRel.addQuery('child', baiItem);
- grRel.query();
- while (grRel.next()) {
- baiList.push(baiItem);
- }
- }
- for (m = 0; m < array1.length; m++)
- var grScan = new GlideRecord('sn_vul_app_scanned_application');
- grScan.addQuery('source=BlackDuck^name1'+ array1[m]);
- grScan.query();
- while (grScan.next()) {
- if (baiList.length > 0) {
- workNotes += application + '-' + baiList.join('-');
- current.work_notes = workNotes;
- } else {
- workNotes += application ;
- current.work_notes = workNotes;
- }
- }
- }
- for(n = 0; n < array2.length; n++) {
- var gr = new GlideRecord('sn_vul_app_scanned_application');
- gr.addEncodedQuery('source=CheckMarx^name=' + array2[n] );
- gr.query();
- while (gr.next()) {
- if (baiList.length > 0) {
- workNotes += application + '-' + baiList.join('-');
- current.work_notes = workNotes;
- } else {
- workNotes += application ;
- current.work_notes = workNotes;
- }
- }
- here is my script please let me know what changes I can do in it or how can I loop through each variable like first I loop through application to check if the have any business application in it then how I can loop through business application variable to check if it is having any sca in it and the sca to check if is having any version it.
- any suggestion !!
- @Brad Bowman
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2024 03:52 PM