Populating CC with Assigned to and logged in user in Workspace
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2024 07:28 AM
Hi,
There is a requirement to create email client template and have the cc populated with current "logged in user" and "assigned to" of the form.But when we put it together as javascript : gs.getUserDisplayName()+" <"+ gs.getUser().getEmail()+">",assigned_to in the cc field its populating both users in ITIL view but not populating anything in workspace. Anyone please suggest how to achieve this in both ITIL and workpace views?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2024 02:58 AM
To achieve this, you can follow the steps below:
1. Navigate to System UI > Email Client Templates.
2. Click on New to create a new template.
3. Fill in the necessary details like Name, Table, Subject, etc.
4. In the CC field, you can use the following script to get the current logged-in user and the assigned_to user:
javascript
javascript: gs.getUserDisplayName()+" <"+ gs.getUser().getEmail()+">,"+current.assigned_to.email
5. Save the template.
However, if the CC field is not populating in the workspace view, it might be due to the workspace not supporting the JavaScript in the CC field.
In such a case, you can create a Business Rule to achieve this:
1. Navigate to System Definition > Business Rules.
2. Click on New to create a new Business Rule.
3. Fill in the necessary details like Name, Table, When to run, etc.
4. In the Advanced tab, you can use the following script:
javascript
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('sys_email');
gr.initialize();
gr.type = 'send-ready';
gr.recipients = current.assigned_to.email;
gr.cc = gs.getUser().getEmail();
gr.subject = 'Subject of the email';
gr.body = 'Body of the email';
gr.insert();
})(current, previous);
5. Save the Business Rule.
This Business Rule will send an email to the assigned_to user and cc the current logged-in user whenever the conditions of the Business Rule are met.
Please note that the above scripts are just examples and might need to be adjusted according to your exact requirements and ServiceNow setup.
Hello All,
For ServiceNow Live Classes, Books, Sample Resumes, Interview Questions, CSA Quizzes.
And getting better servicess on ServiceNow you can visits our website.
Please visit : https://nowkb.com/home
Our Website :https://nowkb.com/home
nowKB.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2024 03:00 AM
Hi
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************