- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2020 12:35 AM
hello,
I have written two inbound actions on tables - incident and u_new_call
Please find the script( This is same for both only written on different tables )
current.short_description = 'Callback request submitted via Voicemail';
current.description = 'Please listen to the voicemail.\n\n' + email.body_text + '\n\n Once called change the log type to denote that follow up was made';
current.u_contact_phone_number = findContactPhone(email.subject);
current.contact_type = 'Callback';
current.assignment_group = new ScriptIncludeName().byPassingName('Group name'); // Script include and group name changed with Generic names
current.insert();
function findContactPhone(subjectLine){
var phoneNumber = /\d+/g.exec(subjectLine);
return phoneNumber.toString();
}
Both new call record and incident is not getting created giving below message:
ServiceDesk New Call Callback : did not create or update u_new_call using current
ServiceDesk New Incident Callback : did not create or update incident using current
How can i resolve this issue?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2020 07:35 AM
Hi Nikita,
when match not found it returns null and hence breaking
we can handle this as below
current.short_description = 'Callback request submitted via Voicemail';
current.description = 'Please listen to the voicemail.\n\n' + email.body_text + '\n\n Once called change the log type to denote that follow up was made';
var subjectLine = email.subject;
var phoneNumber = subjectLine.match(/[+](1-)(\([0-9]{3}\)|[0-9]{3}-)[0-9]{3}-[0-9]{4}/);
// check if not null
if(phoneNumber!=null){
current.u_contact_phone_number = phoneNumber[0]; // using the 1st array element
}
current.contact_type = 'Callback';
current.assignment_group = current.assignment_group = new ScriptIncludeName().byPassingName('Group name');
current.insert();
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2020 04:07 AM
Unfortunately Incident didn't get created and same error comes in the log.
Here is modified script:
current.short_description = 'Callback request submitted via Voicemail';
current.description = 'Please listen to the voicemail.\n\n' + email.body_text + '\n\n Once called change the log type to denote that follow up was made';
current.u_contact_phone_number = findContactPhone(email.subject);
current.contact_type = 'Callback';
current.assignment_group = new ScriptIncludeName().byPassingName('Group name');
current.insert();
function findContactPhone(subjectLine){
var phoneNumber = subjectLine.match(/[+](1-)(\([0-9]{3}\)|[0-9]{3}-)[0-9]{3}-[0-9]{4}/);
return phoneNumber.toString();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2020 04:18 AM
Hi,
the regular expression works fine for me
please don't use function call
use this
current.short_description = 'Callback request submitted via Voicemail';
current.description = 'Please listen to the voicemail.\n\n' + email.body_text + '\n\n Once called change the log type to denote that follow up was made';
var subjectLine = email.subject;
var phoneNumber = subjectLine.match(/[+](1-)(\([0-9]{3}\)|[0-9]{3}-)[0-9]{3}-[0-9]{4}/);
current.u_contact_phone_number = phoneNumber[0]; // use the 1st array element
current.contact_type = 'Callback';
current.assignment_group = new ScriptIncludeName().byPassingName('Group name');
current.insert();
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2020 05:01 AM
Not sure what is going wrong but something with the phone number.
The updated script gave same message, hence i tried adding logs, even logs didn't generated.
here is the script:
current.short_description = 'Callback request submitted via Voicemail';
current.description = 'Please listen to the voicemail.\n\n' + email.body_text + '\n\n Once called change the log type to denote that follow up was made';
var subjectLine = email.subject;
var phoneNumber = subjectLine.match(/[+](1-)(\([0-9]{3}\)|[0-9]{3}-)[0-9]{3}-[0-9]{4}/);
current.u_contact_phone_number = phoneNumber[0]; // using the 1st array element
current.contact_type = 'Callback';
current.assignment_group = current.assignment_group = new ScriptIncludeName().byPassingName('Group name');
current.insert();
gs.log("Phone number from Inc inbound" +current.u_contact_phone_number);
gs.log("Phone number from array" +phoneNumber[0]);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2020 05:05 AM
Hi,
what came in logs for this
Is the field name u_contact_phone_number correct?
gs.log("Phone number from array" +phoneNumber[0]);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2020 05:08 AM
Hi,
I tried in background script and it works well for me
var subjectLine = 'this is email subject phone number is +1-918-000-0000';
var phoneNumber = subjectLine.match(/[+](1-)(\([0-9]{3}\)|[0-9]{3}-)[0-9]{3}-[0-9]{4}/);
var phone = phoneNumber[0];
gs.info(phone);
Output:
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader