Service Catalog: spit out variable values

in an email notification script for example

<mail_script>

var item = new GlideRecord("sc_req_item");
  item.addQuery("sys_id", 'f5a6ff1b37a993c08ca1138943990ee6');
  item.query();
  while(item.next()) {
   
      gs.print(item.number + ":  " + item.cat_item.getDisplayValue() + " \n");
      gs.print("    Options:\n");
      var keys = new Array();
      var set = new GlideappVariablePoolQuestionSet(); 
      set.setRequestID(item.sys_id);
      set.load();
      var vs = set.getFlatQuestions();
      for (var i=0; i < vs.size(); i++) {
        var sLabel=vs.get(i).getLabel();
         if(sLabel != '' && sLabel.indexOf('hidden')<0) { //--RDS Apr2018 hide hidden variables
               var displVal=vs.get(i).getDisplayValue().trim();
               var displVal_len=displVal.length();
                
             if (displVal.length()!=0){  //--RDS Apr2018 dont display empty variables
                 template.print('     ' +  sLabel + " = " + vs.get(i).getDisplayValue() + "\n"); 
              }
        }
      }
  }
</mail_script>

Comments

Popular posts from this blog

Running transform maps asynchronously

Post a command to the ECC queue for the mid server to initiate a powershell file copy

GlideRecord setValue