Email script - show label variable

kristenankeny
Tera Guru

We have email scripts to print the variables from requested items. Below is one example. I was asked to update it to include checkboxes from the form and I have that working, but the label variables above the checkboxes are not showing in the emails. Does anyone know how I would adjust this to show those?

(function runMailScript(current, template, email, email_action, event) {

  for (var key in current.variables) {

  var v = current.variables[key];

  if ( v.getGlideObject().getQuestion().getDisplayValue()!='' && v.getGlideObject().getQuestion().getDisplayValue()!='false' && v.getGlideObject().getQuestion().getLabel() != 'Workflow' && v.getGlideObject().getQuestion().getLabel() != 'Requested for' && v.getGlideObject().getQuestion().getLabel() != 'Phone number') {

  template.space(4);

  var dv = v.getGlideObject().getQuestion().getDisplayValue();

  if (dv.indexOf(',') > -1 && v.getGlideObject().getQuestion().getType() != 2){

  template.print(' ' + v.getGlideObject().getQuestion().getLabel() + ': ' + "</br>");

  var array = dv.split(',');

  for(var a = 0; a < array.length; a++){

  template.space(8);

  template.print(array[a] + "</br>");

  }

  }

  else{

  template.print(' ' + v.getGlideObject().getQuestion().getLabel() + " = " + v.getGlideObject().getQuestion().getDisplayValue() + "<br/>");

  }

  }

  }

})(current, template, email, email_action, event);

1 ACCEPTED SOLUTION

I added a log to my script to see what was found in the variable pool and found that the label variables aren't captured in the variable pool. I'm working with my team to adjust how we label the checkboxes so the email is clearer.


View solution in original post

10 REPLIES 10

I added a log to my script to see what was found in the variable pool and found that the label variables aren't captured in the variable pool. I'm working with my team to adjust how we label the checkboxes so the email is clearer.


Did someone find any solution to this ? I am facing a similar issue

Even I am facing the same issue, is this a known issue

 

 

kristenankeny
Tera Guru

Bump, in case someone can identify the issue in the script.


Hi there,

Any solution or workaround for this issue, for we are facing the same issue and it is much required for the label to be displayed in the notification.

 

Regards,

Kalpana