How to use email.subject.startsWith("test1") method in the inbound action?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2020 04:52 AM
Hi Team,
I am creating the incident through inbound action when email received to system with subject start with "machine"
Email is receiving to system but ticket is not creating and it's showing the error as "did not create or update incident using current"
Script:
var subj = email.subject.toLowerCase();
var subj1 = subj.startsWith("machine");
if (subj1 == true || subj1 == 'true') {
current.u_requestor = 'f5425ad92bde620048dd60ec17da1556';
current.caller_id = 'f5425ad92bde620048dd60ec17da1556';
current.description = email.body_text;
current.short_description = email.subject;
var sub = email.subject;
current.category = " Reporting";
current.subcategory = "Data";
current.incident_state = 10;
current.state = 10;
current.contact_type = "email";
current.assignment_group = '5db01aa413b52e008fda37f1f244b';
current.insert();
}
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2020 05:23 AM
Hi,
Please check with below changes.
if (email.subject.indexOf(toLowerCase("machine"))) >= 0
{
//your code
}
Check and let me know.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2020 05:42 AM
Still, same error is getting and incident is not created.
Please help me on the same
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2020 05:47 AM
Is this an inbound rule in the global scope or a scoped application?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2020 05:54 AM
Hi Sri,
You can do this in the conditions module itself instead of writing the script.
Moreover please check the action type of inbound action also, is it record action or reply email.
apart from this check if the type is New or forward or reply.
Please mark this answer correct if it resolved the query and mark it helpful too if it helped you at all.
Thanks,
Mohit Kaushik
Mohit Kaushik
ServiceNow MVP (2023-2025)