How to autopopulate the TO and CC field in email tab of RITM.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
how to autopopulate the TO and CC field in email tab of RITM. Previously only autopopulate cc(opened_by) and subject. Now i want how find previously working logic and how to find? and i want TO is reqeust for of the request and CC is additional viewers of the request.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
43m ago
You can achieve this by checking the Email Client configuration and identifying the logic that is populating the fields currently.
Since CC (opened_by) is already auto-populating, first verify where the existing logic is configured:
- Navigate to System UI → Email Client → Email Client Configurations
- Check the configuration used for RITM (sc_req_item) table.
- Review the Script section or any associated UI Action / Script Include / Client Script that is populating the CC and Subject fields.
If you want:
- TO = Requested For user
- CC = Additional viewers/watch list users
You can use something like below in the Email Client script:
(function runMailScript(current, emailClient) {
// Populate TO with Requested For
if (current.requested_for.email) {
emailClient.to = current.requested_for.email;
}
// Populate CC with Additional Viewers / Watch List
if (current.watch_list) {
emailClient.cc = current.watch_list;
}
})(current, emailClient);
Also, to find the previously working logic for auto-populated CC and Subject, search for:
- Email Client Configuration on sc_req_item
- UI Actions related to Email
- Scripts referencing emailClient.cc or emailClient.subject
You can search globally for keywords like:
emailClient
emailClient.cc
emailClient.to
This should help you identify the existing implementation and extend it for the TO field as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11m ago - last edited 11m ago
@sureshpalla i was check the email client configuraiton but no related items for sc_req_item in my instance. so iwant go with email client template(sys_email_client_template) and how to get catalog varibales additional viewers field to mapped CC ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
7m ago
If you are using Email Client Template (sys_email_client_template) and there is no Email Client Configuration for sc_req_item, you can populate the TO and CC fields using a script in the template or by referencing the RITM variables.
For TO = Requested For:
current.requested_for.email
For mapping Additional Viewers catalog variable to CC, first access the variable value from RITM variables:
var ccUsers = current.variables.additional_viewers;
If the variable is a List Collector / Reference field (sys_user), you need to fetch email addresses:
var ccEmails = [];
var userGR = new GlideRecord('sys_user');
userGR.addQuery('sys_id', 'IN', current.variables.additional_viewers);
userGR.query();
while (userGR.next()) {
if (userGR.email)
ccEmails.push(userGR.email.toString());
}
template.cc = ccEmails.join(',');
template.to = current.requested_for.email.toString();
Also verify whether additional_viewers is a catalog variable name or mapped to a field on sc_req_item. If it is a variable, you can access it through current.variables.<variable_name>.