Is there a way to automatically forward an email that has not been processed?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-05-2024 07:18 AM
For one of my customers, a lot of users end up being deactivated incorrectly and when they send an email it does not get processed because they're not active. Is there a way to create a flow where this email would be automatically forwarded to the Service Desk so they would be able to forward themselves to ServiceNow and thus process it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-05-2024 11:32 PM
Yes, you can create a flow to handle this situation. Here's a high-level overview of how you might approach this:
1. Create an Inbound Email Action: This is the first step where you define what should happen when an email is received. You can specify the conditions under which this action should be triggered. For example, you can set it to trigger when an email is received from a deactivated user.
2. Create a Business Rule: This rule will be triggered when the Inbound Email Action is executed. The rule can check if the user is active or not. If the user is not active, the rule can forward the email to the Service Desk.
3. Configure the Service Desk Email: You need to configure the Service Desk email to accept forwarded emails and process them accordingly. This can be done in the Email Properties of the Service Desk.
4. Test the Flow: Finally, you should test the flow to ensure that it works as expected. Send an email from a deactivated user and check if it gets forwarded to the Service Desk.
Here's a sample code for the Business Rule:
javascript
(function executeRule(current, previous /*null when async*/) {
// Query the sys_user table to check if the user is active
var user = new GlideRecord('sys_user');
user.addQuery('email', current.from);
user.query();
if (user.next()) {
// If the user is not active, forward the email to the Service Desk
if (!user.active) {
gs.eventQueue('x_snc_my_namespace.forward.to.service.desk', current, user.email, current.body);
}
}
})(current, previous);
This code assumes that you have an event named 'x_snc_my_namespace.forward.to.service.desk' that handles the email forwarding. You would need to create this event and define its actions. Remember to replace 'x_snc_my_namespace' with your own namespace.
For asking ServiceNow-related questions try this :
For a better and more optimistic result, please visit this website. It uses a Chat Generative Pre-Trained Transformer ( GPT ) technology for solving ServiceNow-related issues.
Link - https://nowgpt.ai/
For the ServiceNow Certified System Administrator exams try this :
https://www.udemy.com/course/servicenow-csa-admin-certification-exam-2023/?couponCode=NOW-DEVELOPER