The CreatorCon Call for Content is officially open! Get started here.

Email script to show variables visible on summary

Rajesh Mushke
Mega Sage

Hi Team,

we have an email notification when an item is submitted, here we need to show variables visible on summary.

can any one suggest me how to show variables visible on summary using email script.



Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke
1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

You can use this code in a mail script to print variables. This one assumes the message is on the sysapproval_approver table and gets the variables from the record pointed to by the sysapproval table.



printVars();


function printVars(){


      var set = new GlideappVariablePoolQuestionSet();


      set.setRequestID(current.getValue('sysapproval'));


      set.load();


      var vs = set.getFlatQuestions();


      for (var i=0; i < vs.size(); i++) {


              if(vs.get(i).getLabel() != '') {


                      template.print('       ' +   vs.get(i).getLabel() + " = " + vs.get(i).getDisplayValue() + "\n");


              }


      }


}


View solution in original post

13 REPLIES 13

Hi Alexander,



I recommend you send a message to docs@servicenow.com to get it in their queue to document the API.


Thank you so much ctomasi   , given script perfectly working.



i need one more help, i want bold only variable names not for the variable values, please help me on this.....




Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke

Do this



printVars();


function printVars(){


      var set = new GlideappVariablePoolQuestionSet();


      set.setRequestID(current.getValue('sysapproval'));


      set.load();


      var vs = set.getFlatQuestions();


      for (var i=0; i < vs.size(); i++) {


              if(vs.get(i).getLabel() != '') {


                      template.print('     <b>' +   vs.get(i).getLabel() + "</b> = " + vs.get(i).getDisplayValue() + "\n");


              }


      }


}



Please mark this response as correct or helpful if it assisted you with your question.

Perfect, small change with bold tag and thank you so much.....




Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke

script displaying all the catalog variables in summary irrespective of mandatory and non mandatory (filling or not filling)variables.

can you please help me with the script if in case there is no data in variables to hide those variables in summary.

 

Thanks!!!