- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello Community,
Need your help!
Add alert message on click email OR highlight email adress in color when the reqested for is VIP user,
once we click on email, we get Email compose popup,
Or you can help me with an ideas, I am not getting the way or easy way to chive this requirement,
Thank you
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @VarshaSambha,
I've had a quick look and because the Email Composer is a free text field, it wouldn't be straight forward to have it show on that UI.
I'd propose considering highlighting the 'Requested for' on the Catalog Task view instead so it's clear the requestor is a VIP.
This was possible using a Client Script with a Script Include.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @VarshaSambha ,
Just to confirm my understanding of the requirement:
When an agent opens a Catalog Task and clicks the standard Email option from the top-right menu, what should happen if the Requested for user is marked as a VIP?
Should a warning message appear before opening the email composer?
Should the email composer be visible and accessible only for VIP users, while it should be disabled or unavailable for non-VIP users?
Alternatively, should the email composer open for both VIP and non-VIP users, but the VIP user's email address in the To field should be highlighted in a different color?
For non-VIP users, should the standard email functionality remain unchanged, or should they be prevented from composing emails entirely?
Could you please confirm the expected behavior so I can suggest the most appropriate solution?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi Bhavani,
Thank you for your response,
yes, When an agent opens a Catalog Task and clicks the standard Email option from the top-right menu, if the Requested for is a VIP then
1 A warning or alert message should appear before opening the email composer
OR
3 if Requested for is VIP then email address in the To field should be highlighted in a different color.
I hope you will get the qusetion.
waiting for your response.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @VarshaSambha ,
Thankyou for confirming the Question.
There are two possible approaches for this requirement. The implementation depends on whether you want to warn the agent before opening the email composer or visually highlight the VIP recipient in the To field.
Approach 1: Display a warning before opening the Email composer
You can create a custom UI Action on the Catalog Task (sc_task) form that checks whether the Requested for user is marked as VIP. If the user is a VIP, it displays a confirmation message before opening the email composer.
Step 1: Create a UI Action
Navigate to System Definition → UI Actions and create a UI Action with the following configuration:
Name: Email (VIP Check)
Table: Catalog Task [sc_task]
Client: Checked
Form button: Checked
Onclick: openEmailWithVIPCheck()
Add the following script:
function openEmailWithVIPCheck() {
var requestedFor = g_form.getValue('requested_for');
if (!requestedFor) {
emailClientOpenPop('sc_task');
return;
}
g_form.getReference('requested_for', function(user) {
if (user && user.vip == 'true') {
var proceed = confirm(
'Warning: The Requested for user is a VIP. ' +
'Please verify the recipient before sending the email. ' +
'Do you want to continue?'
);
if (!proceed) {
return;
}
}
emailClientOpenPop('sc_task');
});
}Important: This example assumes that requested_for is a reference field on sc_task and that the referenced user record has the standard vip field. Verify the actual field names in your instance and adjust the script if Requested for is populated through the requested item or a custom field.
Step 2: Test the implementation
Open a Catalog Task.
Click the new Email (VIP Check) button.
If Requested for is a VIP, a confirmation message appears.
Selecting Cancel prevents the composer from opening.
Selecting OK opens the email composer.
Limitation: This creates a separate custom UI Action. It does not automatically intercept the existing standard Email option in the form's More options menu. Replacing or intercepting that existing option would require additional UI customization, which should be evaluated for upgrade compatibility.
Approach 2: Populate the To field using an Email Client Template
If the goal is to ensure the email composer opens with the correct recipient populated, an Email Client Template can be used.
Step 1: Create a Script Include
Navigate to System Definition → Script Includes and create a server-side Script Include to return the requested user's email address.
Example:
var CatalogTaskEmailHelper = Class.create();
CatalogTaskEmailHelper.prototype = {
initialize: function() {},
getRequestedForEmail: function(taskSysId) {
var task = new GlideRecord('sc_task');
if (!task.get(taskSysId)) {
return '';
}
// Adjust this field path to match your instance.
var requestedFor = task.getValue('requested_for');
if (!requestedFor) {
return '';
}
var user = new GlideRecord('sys_user');
if (user.get(requestedFor)) {
return user.getValue('email') || '';
}
return '';
},
type: 'CatalogTaskEmailHelper'
};This is a server-side example. The actual field path must be verified in your instance. If Requested for is available through a reference such as the requested item, update the lookup accordingly.
Step 2: Configure the Email Client Template
Navigate to System Definition → Email Client Templates and create a template for Catalog Task.
Configure the applicable table and template fields. In the To field, use a supported javascript: expression that calls a server-side Script Include to return a comma-separated recipient address.
For example, the intended logic is:
javascript: new CatalogTaskEmailHelper().getRequestedForEmail(/* current task sys_id */);The exact expression for obtaining the current task's sys_id must match the execution context supported by your ServiceNow release and email-template configuration. Validate this in a sub-production instance before deployment; do not assume that current or a task identifier is automatically available in every template context.
Step 3: Validate the result
Open a Catalog Task.
Open the Email composer using the configured template.
Confirm that the expected email address appears in the To field.
Test with both VIP and non-VIP users.
Confirm that the template does not populate an unintended recipient when the reference or email address is empty.
Important: An Email Client Template helps populate the recipient; it does not, by itself, guarantee a VIP warning or highlight the recipient in the composer. If the template should behave differently for VIPs, configure and test the applicable template conditions and recipient logic separately.
Can we highlight the VIP email address in the To field?
There is no standard Email Client Template setting that conditionally highlights an individual recipient's email address in the composer based on the user's VIP flag.
Achieving that behavior would require customization of the email composer UI, and the implementation would depend on whether your instance uses the classic email client or the Next Experience email client. Such customization should be reviewed for upgrade compatibility.
My Recommendation:
For a warning before sending: Approach 1 is the more straightforward starting point, with the caveat that it uses a separate custom action.
For automatic recipient population: Approach 2 is suitable when the template context and requested-user field mapping are verified.
For the existing standard Email menu option: Neither example automatically intercepts that option. Confirm the email client's supported extension points before attempting to replace or modify its behavior.
Official references:
If this answer helps, please mark it as helpful.
ThankYou
Yamsani Bhavani
ServiceNow Developer - SecOps, GRC, Custom Applications, Now Assist
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @VarshaSambha,
I've had a quick look and because the Email Composer is a free text field, it wouldn't be straight forward to have it show on that UI.
I'd propose considering highlighting the 'Requested for' on the Catalog Task view instead so it's clear the requestor is a VIP.
This was possible using a Client Script with a Script Include.