- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5 hours ago
I have created a inbound action, when I send an email the inbound action is creating the case record which I can see on the email logs but the same record is not visible on the list or on the target field
Similar case I found below but no solution for this yet..
https://www.servicenow.com/community/csm-forum/created-a-record-by-inbound-action-but-not-showing-in...
@Tanushree Maiti @Ankur Bawiskar
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5 hours ago
1)Refer KB: KB0547763 Empty Target record on processed emails
Cause
When an inbound action processes an incoming email, it uses the variable current to represent the record that it affects.
If a new record is to be created, then-current represents a new empty record for the target table suitable for the population before an insert.
1 2 3 4 5 6 7 8 9 10 11 12 | //Sample inbound action script creates an incident record current.caller_id = gs.getUserID(); current.comments = "received from: " + email.origemail; current.short_description = email.subject; current.category = "request"; current.incident_state = 1; current.notify = 2; current.contact_type = "email"; current.insert(); //<--When line completes, it will update the target |
If an existing record is to be updated, then current represents a reference to the record that is to be updated.
1 2 3 4 5 6 7 8 9 10 11 12 13 | gs.include('validators');
if (current.getTableName() == "incident") {
current.comments = "reply from: " + email.origemail;
if (email.subject.toLowerCase().indexOf("please reopen") >= 0) {
current.state = "2";
current.work_notes = "Issue was not resolved";
}
current.update(); //<--When this line completes, it will update the Target field |
If the script does not use variable current to update or create a record, the system does not know which record was affected and therefore is not able to fill in the Target field.
Resolution
- Whenever possible, use the already-provided current to update or create the target record.
Or: - If this is not an option because the script updates a record that does not belong to the Target table, or if you update/create more than one record, then consider manually logging the changes made by your custom action using gs.log() as described in product documentation.
1 2 3 4 5 6 7 8 | var grIncident = new GlideRecord('incident');
grIncident.initialize();
grIncident.caller_id=gs.getUserID();
grIncident.comments = "received from: " + email.origemail;
grIncident.short_description = email.subject;
grIncident.insert();
//create log entry to know what created/update by this action
gs.log("<custom_action_name> Created Incident:" + grIncident.number, "EMAIL." + sys_email.sys_id); |
You should then be able to view the record that was created or updated in the email logs.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5 hours ago
1)Refer KB: KB0547763 Empty Target record on processed emails
Cause
When an inbound action processes an incoming email, it uses the variable current to represent the record that it affects.
If a new record is to be created, then-current represents a new empty record for the target table suitable for the population before an insert.
1 2 3 4 5 6 7 8 9 10 11 12 | //Sample inbound action script creates an incident record current.caller_id = gs.getUserID(); current.comments = "received from: " + email.origemail; current.short_description = email.subject; current.category = "request"; current.incident_state = 1; current.notify = 2; current.contact_type = "email"; current.insert(); //<--When line completes, it will update the target |
If an existing record is to be updated, then current represents a reference to the record that is to be updated.
1 2 3 4 5 6 7 8 9 10 11 12 13 | gs.include('validators');
if (current.getTableName() == "incident") {
current.comments = "reply from: " + email.origemail;
if (email.subject.toLowerCase().indexOf("please reopen") >= 0) {
current.state = "2";
current.work_notes = "Issue was not resolved";
}
current.update(); //<--When this line completes, it will update the Target field |
If the script does not use variable current to update or create a record, the system does not know which record was affected and therefore is not able to fill in the Target field.
Resolution
- Whenever possible, use the already-provided current to update or create the target record.
Or: - If this is not an option because the script updates a record that does not belong to the Target table, or if you update/create more than one record, then consider manually logging the changes made by your custom action using gs.log() as described in product documentation.
1 2 3 4 5 6 7 8 | var grIncident = new GlideRecord('incident');
grIncident.initialize();
grIncident.caller_id=gs.getUserID();
grIncident.comments = "received from: " + email.origemail;
grIncident.short_description = email.subject;
grIncident.insert();
//create log entry to know what created/update by this action
gs.log("<custom_action_name> Created Incident:" + grIncident.number, "EMAIL." + sys_email.sys_id); |
You should then be able to view the record that was created or updated in the email logs.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti