Initialize Input Data

The Complete Script for the Custom Audit 1 task initializes the auditRequest data field.

This field is set to a type of eventObject (external reference), which is the data type that is sent to the Event Collector Audit service.

The script reads as follows:

auditRequest = com_tibco_n2_ec_api_Factory.createeventObject();
auditRequest.event = com_tibco_n2_ec_api_base_Factory.createEvent();
/*
 * Recommended Attributes, the minimum required attributes should be included
 */
auditRequest.event.correlationId = "customAudit";
auditRequest.event.eventTimestamp = DateTimeUtil.createDatetimetz();
var a = com_tibco_n2_ec_api_base_Factory.createAttribute();
a.attributeId = -1;
a.attributeName = "managedObjectId";
a.value = Process.getId();
auditRequest.event.attribute.add(a);
a = com_tibco_n2_ec_api_base_Factory.createAttribute();
a.attributeId = -1;
a.attributeName = "managedObjectName";
a.value = Process.getName();
auditRequest.event.attribute.add(a);
a = com_tibco_n2_ec_api_base_Factory.createAttribute();
a.attributeId = -1;
a.attributeName = "componentId";
a.value = "ECCustomAudit";
auditRequest.event.attribute.add(a);
a = com_tibco_n2_ec_api_base_Factory.createAttribute();
a.attributeId = -1;
a.attributeName = "messageCategory";
a.value = "CUSTOM";
auditRequest.event.attribute.add(a);
a = com_tibco_n2_ec_api_base_Factory.createAttribute();
a.attributeId = -1;
a.attributeName = "principalId";
a.value = Process.getOriginator();
auditRequest.event.attribute.add(a);
a = com_tibco_n2_ec_api_base_Factory.createAttribute();
a.attributeId = -1;
a.attributeName = "principalName";
a.value = Process.getOriginatorName();
auditRequest.event.attribute.add(a);
a = com_tibco_n2_ec_api_base_Factory.createAttribute();
a.attributeId = -1;
a.attributeName = "managedObjectType";
a.value = "customAudit";
auditRequest.event.attribute.add(a);
/*
 * Custom Attributes here!
 * In this example the data (attrVal) is assigned to the attribute (attrName)
 * entered in the previous form
 */
a = com_tibco_n2_ec_api_base_Factory.createAttribute();
a.attributeId = -1;
a.attributeName = attrName;
a.value = attrVal;
auditRequest.event.attribute.add(a);
/*
 * Attributes below are mandatory and should contain valid values
 * These are currently assigned the values entered in the previous form
 */
auditRequest.event.message = msg;
auditRequest.event.messageId = msgId;
auditRequest.event.priority = priority;
auditRequest.event.severity = severity;