need to create RITM based from email or outlook like based on email content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2025 06:09 AM
HI experts,
email content:
-----------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2025 06:30 AM
this link has solution using Flow, please enhance
Create RITM through inbound action by parsing mail body
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2025 08:04 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2025 06:56 AM - edited 03-20-2025 08:10 PM
Hello @Purushotham Ga2
There are two ways with which you can achieve your requirement:
1. Flow (No code or low code): https://www.youtube.com/watch?v=uLHCw2GA3lo&t=363s
ServiceNow official information and instructions: https://developer.servicenow.com/dev.do#!/learn/courses/xanadu/app_store_learnv2_flowdesigner_xanadu...
2. Inbound Actions (System Policy > Email > Inbound Actions) - Development
Here is a sample Background script with the e-mail body example you shared:
//var body = email.body_text; // In your inbound email Actions script you will use it to extract plain text body
var emailBody =
"User S Admin has been disabled due to inactivity.\n" +
"User Name - Testssrm_1\n" +
"Job Title - Security Service\n" +
"AD Last Logon - 11/08/2024 04:50:13\n" +
"Azure AD Last Sign-In - 11/08/2024 04:50:13\n" +
"Manager - Putt\n" +
"Manager Email ID - zyelynn.putt@abc.com\n" +
"Business Process: Disablement: Testssrm_1 (Disabled)\n" +
"Subject: Admin account Testssrm_1 disabled by AD automation due to inactivity\n" +
"Details: Admin account Testssrm_1 disabled by AD automation due to inactivity and disabled on 2/11/2025 12:42:54 AM";
// Initialize the Request Item (RITM) record
var ritmGr = new GlideRecord('sc_req_item');
ritmGr.initialize();
// Item field (cat_item).. if you already have 'Admin account Testssrm_1 disabled by AD automation due to inactivity' as cat_item then use it's sys_id as it is a reference field
ritmGr.setValue('cat_item', 'YOUR_CATALOG_ITEM_SYS_ID');
// Extract values using regular expressions (https://regexr.com/)
var userNameMatch = emailBody.match(/User Name - (.+)/); // (.+) captures anything after the User Name -
var jobTitleMatch = emailBody.match(/Job Title - (.+)/);
var adLogonMatch = emailBody.match(/AD Last Logon -\s*(.+)/);
var azureLogonMatch = emailBody.match(/Azure AD Last Sign-In -\s*(.+)/);
var managerMatch = emailBody.match(/Manager - (.+)/);
var managerEmailMatch = emailBody.match(/Manager Email ID - (.+)/);
// Set values in RITM variables. Reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match
ritmGr.variables.user_name = userNameMatch ? userNameMatch[1].trim() : '';
ritmGr.variables.job_title = jobTitleMatch ? jobTitleMatch[1].trim() : '';
ritmGr.variables.ad_last_logon = adLogonMatch ? new GlideDateTime(adLogonMatch[1].trim()) : '';
ritmGr.variables.azure_ad_last_sign_in = azureLogonMatch ? new GlideDateTime(azureLogonMatch[1].trim()) : '';
ritmGr.variables.manager_name = managerMatch ? managerMatch[1].trim() : '';
ritmGr.variables.manager_email_id = managerEmailMatch ? managerEmailMatch[1].trim() : '';
gs.info(userNameMatch ? userNameMatch[1].trim() : '');
gs.info(jobTitleMatch ? jobTitleMatch[1].trim() : '');
gs.info(adLogonMatch ? new GlideDateTime(adLogonMatch[1].trim()) : '');
gs.info(azureLogonMatch ? new GlideDateTime(azureLogonMatch[1].trim()) : '');
gs.info(managerMatch ? managerMatch[1].trim() : '');
gs.info(managerEmailMatch ? managerEmailMatch[1].trim() : '');
/* Insert RITM record in your actual inbound email action script.
var ritmSysId = ritmGr.insert();
if (ritmSysId) {
gs.info("RITM created successfully with sys_id: " + ritmSysId);
} else {
gs.error("Failed to create RITM.");
} */
Results:
Please perform the development and let us know your results so that we all can learn together.
Hope that helps!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2025 08:25 PM
HI @Vishal Jaswal - i used the above script but it's not working like just populate the manager details only but it doesnt capture in variables. please assist me on this asap