How can i pass user email address from incident form to MIM communication task recipient?

Ankit Kumar6
Tera Contributor

Hi Team,

I have a list field on the Incident form where multiple users can be selected. My requirement is: when multiple users are selected in this field, their email addresses should be passed to the "To" field of the MIM Workbench Communication Task as recipients.

Could you please guide me on how this can be implemented?

11 REPLIES 11

@Ankit Kumar6 

 

Refer below for sample code, customize according to your business requirements

var res=''; 
var mim_recipients=[];
var IncGr = new GlideRecord(sourceTable);
IncGr.addQuery("sys_id", commPlanSourceId);
IncGr.query();
while (IncGr.next()) {
//<Add your business logic to retrieve list of users in Incident table and do a glide record query with while loop>
{
res += ',' + gr.<user_field>;
}
res=res.replace(",", "");
mim_recipients=res.split(',');
var unique_recipients_list = new global.ArrayUtil().unique(mim_recipients);
var obj = {'internal' : unique_recipients_list};
return obj;
}})();

 

Thanks,

Bhuvan

Its not Working

@Ankit Kumar6 

 

Can you share the code you have created and more details regarding steps you followed ?

 

Thanks,

Bhuvan

Hi @Bhuvan  

Please find the script below:

function email() {
var customer = current.u_affected_customer.toString().split(',');
var emailList = [];
for (var i = 0; i < customer.length; i++) {
var company = new GlideRecord('core_company');
company.addQuery('sys_id', customer[i]);
company.query();
while (company.next()) {
if (company.email) {
emailList.push(company.email);
}

}
}
var uniqueEmail = new global.ArrayUtil().unique(emailList);
var obj = {'internal': uniqueEmail};
return obj;
}
email();

Hi Ankit,

 

If you are trying to pass email IDs from Incident table [source table] to MIM Work bench Communication Task table, not sure why you are gliding records on company table.

 

If possible can you share screenshots of your configuration and explain in detail what you are trying to achieve so as to refine the code ?

 

Thanks,

Bhuvan