// ServiceNow

Displaying the variable fields of the request item in a mail script

When the variable fields in the created request form need to be sent via email, the following mail script will solve your task quite practically.

  1. sysevent_register table needs a record to be defined (sendto.ibm.ritm). sc_req_item should be selected as the table. (We will select this record in the Notification and trigger this record in the UI Action.)
  2. A Notification needs to be defined. It should be “When send: Event is fired“, and “Message Html: ${mail_script:st_sendto_ibm_ritm}” should be added. (We will trigger sending this message.)

3. UI Action Content to trigger the email sending:

gs.eventQueue('sendto.ibm.ritm',current,current.number,gs.getUserName());
gs.addInfoMessage("IBM'e bilgilendirme epostası gönderilmiştir.");
action.setRedirectURL(current);

 

4. Email script content:

var set = new GlideappVariablePoolQuestionSet();
set.setRequestID(current.sys_id.toString());
set.load();

var vs = set.getFlatQuestions();
for (var i = 0; i < vs.size(); i++) {
    if (vs.get(i).getLabel() != '' && vs.get(i).getDisplayValue() != '' && vs.get(i).getDisplayValue() != 'false') {
        template.print(' ' + vs.get(i).getLabel() + " = " + vs.get(i).getDisplayValue() + "<br/>");
    }
}

 

// JOIN THE CONVERSATION

Share your experience

Bir sorunun, farklı bir çözümün veya eklemek istediğin bir notun var mı? Giriş yapmadan da yazabilirsin.

// KEEP READING

One more note.

All posts ↗︎