how to pass the mrvs multirow data set value in work note

keshav77
Tera Contributor
  1. Hi Team I want to pass the data from multirow variables set(mrvs) to work note I am having 5 variables in mrvs.
  2. 1.applications  2.business_application_bai 3.SCA 4.SAST 5. VERSION. note these all are list collector type
  3.  
  4. here variable 1 and 2 is having parent child relationship the data is coming from cmdb_rel_ci.
  5.  
  6. 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.
  7. 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..
  8. As of now My script providing every possible combination which possible. but I want unique combination which is related one like this 
  9.  
  10. Application1-BusinessApplication1 Application2-BusinessApplication3 Application3-BusinessApplication4 Application4 Application5-BusinessApplication6
  11.  
  12. var array1 = [];
  13. var array2 = [];
  14. var array3 = [];
  15. var array4 = [];
  16. var array5 = [];
  17. var array6 = [];
  18. var array7 = [];
  19.  
  20. var appl = current.variables.application_information;
  21. var totalRows = appl.getRowCount();
  22.  
  23. for (var i = 0; i < totalRows; i++) {
  24.     var applications = appl.getRow(i).getCell('applications').getCellDisplayValue();
  25.     var bai = appl.getRow(i).getCell('business_application_bai').getCellDisplayValue(); // BAI 
  26.     var name1 = appl.getRow(i).getCell('name').getCellDisplayValue();
  27.     var name2 = appl.getRow(i).getCell('names').getCellDisplayValue(); // Added name2
  28.     var version = appl.getRow(i).getCell('application_version').getCellDisplayValue();
  29.  
  30.     gs.log("Row " + i + ": applications=" + applications + ", name1=" + name1 + ", name2=" + name2 + ", version=" + version);
  31.  
  32.     array1 = name1.replace(/\s*\,\s*/g, ",").trim().split(',');
  33.     array2 = name2.replace(/\s*\,\s*/g, ",").trim().split(','); // Added array2
  34.     array3 = version.replace(/\s*\,\s*/g, ",").trim().split(",");
  35.     array4 = applications.replace(/\s*\,\s*/g, ",").trim().split(',');
  36.     array5 = bai.replace(/\s*\,\s*/g, ",").trim().split(','); // Added for business_application_bai
  37. }
  38.  
  39. var workNotes = ''; 
  40.  
  41. for (var i = 0; i < array4.length; i++) {
  42.     var application = array4[i];
  43.  
  44. var baiList = [];
  45.     
  46.     for (var j = 0; j < array5.length; j++) {
  47.         var baiItem = array5[j];
  48.         var grRel = new GlideRecord('cmdb_rel_ci');
  49.         grRel.addEncodedQuery("child.sys_class_name=u_cmdb_busapp_instance^parent.sys_class_name=cmdb_ci_business_app");
  50.         grRel.addQuery('parent', application);
  51.         grRel.addQuery('child', baiItem);
  52.         grRel.query();
  53.         while (grRel.next()) {
  54.             baiList.push(baiItem);
  55.         }
  56.     }
  57. for (m = 0; m < array1.length; m++) 
  58.     var grScan = new GlideRecord('sn_vul_app_scanned_application');
  59.     grScan.addQuery('source=BlackDuck^name1'+ array1[m]);
  60.     grScan.query();
  61.     while (grScan.next()) {
  62.         if (baiList.length > 0) {
  63.             workNotes += application + '-' + baiList.join('-');
  64. current.work_notes = workNotes;
  65.         } else {
  66.             workNotes += application ;
  67. current.work_notes = workNotes;
  68.         }
  69.     }
  70. }
  71.  
  72. for(n = 0; n < array2.length; n++) {
  73.         var gr = new GlideRecord('sn_vul_app_scanned_application');
  74.         gr.addEncodedQuery('source=CheckMarx^name=' + array2[n] );
  75.         gr.query();
  76.         while (gr.next()) {
  77.             
  78.            if (baiList.length > 0) {
  79.             workNotes += application + '-' + baiList.join('-');
  80. current.work_notes = workNotes;
  81.         } else {
  82.             workNotes += application ;
  83. current.work_notes = workNotes;
  84.         }
  85. }
  86. 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.
  87.  
  88. any suggestion !!
  89. @Brad Bowman
1 REPLY 1

Murthy Ch
Giga Sage

Hello @keshav77 

It is really hard to answer this question untill I'm having clear data structure on your system.
Check my article for more understanding on MRVS.

Let me know if you still stuck to solve your issue. I will try to dig into it.

 

 

Thanks,
Murthy