Custom field in Event (em_event) table to be populated in custom field in Alert (em_alert)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2019 02:30 AM
I have to create a custom field in event table to map the field values from Soap based source integration as listener transform script cannot be use in case of SOAP.
I have to mapped these custom field from event table to Alert table. I have created business rule to populate custom field in alert table.Business rule after insert on alert table and query for reference alert field in event table.Based on query result, value need to be copied from custom field of event to alert.
Below logic is not working.Also is there any alternative way to sync event to alert custom field.
-------------------------------------------
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var em = new GlideRecord('em_event');
em.addQuery('alert', current.sys_id);
em.query();
if (em.next()){
if(JSUtil.notNil(em.u_audit_error_links)){
current.u_audit_error_links = em.u_audit_error_links;
current.update();
}
}
})(current, previous);
- Labels:
-
Event Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2019 09:55 AM
Nitin,
I just created an event with a SOAP call:
I just passed a JSON body as a string to the additional_info field.
Here's the python script I used, as you can see in the "values" structure additional_info has JSON string and it maps ok:
from SOAPpy import SOAPProxy
import sys
def createEvent(params_dict):
# instance to send to
instance = 'your_instance_name'
# username/password
username = 'you_username'
password = 'your_password'
# proxy - NOTE: ALWAYS use https://INSTANCE.service-now.com,
# not https://www.service-now.com/INSTANCE for web services URL from now on
proxy = 'https://%s:%s@%s.service-now.com/em_event.do?SOAP' % (username,
password,
instance)
namespace = 'http://www.service-now.com/'
server = SOAPProxy(proxy, namespace)
# uncomment these for LOTS of debugging output
# server.config.dumpHeadersIn = 1
# server.config.dumpHeadersOut = 1
# server.config.dumpSOAPOut = 1
# server.config.dumpSOAPIn = 1
response = server.insert(
source=params_dict['source'],
node=params_dict['node'],
type=params_dict['type'],
severity=int(params_dict['severity']),
resource=params_dict['resource'],
additional_info=params_dict['additional_info'],
description=params_dict['description'])
return response
values = {
'source':
'SOAP_Event_GP',
'node':
'SOAP_Node',
'type':
'SOAP_Test',
'severity':
'5',
'resource':
'SOAP_Resource',
'additional_info':
'{"u_cid":"JSON_IN_SOAP"}',
'description':
'Creating an event via SOAP call passing JSON for Additiona_info'
}
new_incident_sysid = createEvent(values)
print "Returned sysid: " + repr(new_incident_sysid)
Again, as previously stated, do not modify the em_event table, it's not supported.
Showing the event structure and the desired resulting alert structure could also help understanding what you are trying to do.
I hope this helps,
Gp