How to set dynamic recipient to the email notification using email scripts
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2023 02:56 AM
Here is the code I'm using to set the recipient of an email notification as the variable on catalog task form using email script:
This log: gs.log('asset received3' +Useremail); is giving the correct value but still the notification is not being sent to this user instead it is getting sent to the request_for variable which i have selected in who will receive tab on notification page.
var taskGR = new GlideRecord('sc_task');
taskGR.get(current.sys_id);
var recipient = current.variables.asset_assigned_to_user;
gs.log('asset received' +recipient);
var userGR = new GlideRecord('sys_user');
userGR.get(recipient);
//current.variables.recipient = userGR.getValue('email');
var Useremail = userGR.getValue('email');
gs.log('asset received3' +Useremail);
email.setReplyTo(Useremail);
What could possibly go wrong here.
Thank in advance
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2023 10:26 AM
@Yash38 use this in last line
email.addAddress("to", userGR.email,userGR.name);
Bharath Chintala
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2023 04:21 AM
Hi @BharathChintala ,
It's not working.
logs are giving me the email id of the desired user but somehow email is not being sent.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2023 04:43 PM
@Yash38 Can you send screenshots of notification and script
Bharath Chintala
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2023 04:45 PM
@Yash38 Did you call email script in body only write
${mail_script:ScriptName}
in above format
Bharath Chintala