Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Font Color in mail Script

Brian Lancaster
Kilo Patron

I'm running the following mail script and they would like the part highlighted in red to be the font color of red.   If I try and add the HTML code for font color it fails and nothing shows up in the email.   How can I get this one section to be in red.

 

<hr/>

<mail_script>

  template.print("Summary of Requested item:\n");

  var item = new GlideRecord("sc_req_item");

  item.addQuery("sys_id", current.sys_id);

  item.query();

  while(item.next()) {

          template.print(item.number + ":   " + item.cat_item.getDisplayValue() + "\n");

          template.print("       Item 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++) {

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

                    template.space(4);

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

              }

          }

  }

</mail_script>

1 ACCEPTED SOLUTION

donnie5
Mega Expert

Either something like:



template.print('         ' +   vs.get(i).getLabel() + " = <span style=\"color:red\">" + vs.get(i).getDisplayValue() + "</span>\n");



or:



template.print('         ' +   vs.get(i).getLabel() + " = <span style='color:red'>" + vs.get(i).getDisplayValue() + "</span>\n");



should work. We use similar things in our notifications.



If not, check the logs or maybe turn on JS Debug to see if more information is available on what it doesn't like.


View solution in original post

3 REPLIES 3

donnie5
Mega Expert

Either something like:



template.print('         ' +   vs.get(i).getLabel() + " = <span style=\"color:red\">" + vs.get(i).getDisplayValue() + "</span>\n");



or:



template.print('         ' +   vs.get(i).getLabel() + " = <span style='color:red'>" + vs.get(i).getDisplayValue() + "</span>\n");



should work. We use similar things in our notifications.



If not, check the logs or maybe turn on JS Debug to see if more information is available on what it doesn't like.


Hi, is there a way to highlight a specific text? I tried <mark> TEXT </mark> but it doesnt do anything.


Thanks!


Brian Lancaster
Kilo Patron

It was the second code listed that worked.