Scripted Audit Creating the Same Task Multiple Times
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2023 04:28 PM
Hello all. I have a scripted audit where it records service offerings for compliance, and in the code below, it checks whether the Business Contact field of the TSO is valid and if the user is active.
One of my requirements is to create a task where if the audit result is failed, I am to create a task for that audit.
I've added the following code before the certification processing of the audit:
var followOnTask = new SNC.CertificationProcessing().createFollowOnTask(current.sys_id, sysId, assignToUser, '', taskMsg);but the problem is that this code would generate the same task every time the audit has been ran.
Is there a way I could manipulate the code to make it so that they won't have to create a duplicate task when it is already generated and still in open state?
I've tried one of the system properties that the documentation mentioned to set to false to prohibit the creation of the same task, but it didn't work.
This is just a part of the scripted audit for reference.
var certProcessor;
if (gs.getCurrentScopeName().includes("global"))
certProcessor = new SNC.CertificationProcessing();
else {
certProcessor = new CertificationProcessing();
}
// API call to retrieve records based on the filter
var gr = new SNC.CertificationProcessing().getFilterRecords(current.filter);
// Loop over all records defined by the filter
while (gr.next()) {
var pass = true;
var columnNameSpace = '';
var hasAvailability = false;
var userGr = new GlideRecord('sys_user');
var soCommitmentGr = new GlideRecord('service_offering_commitment');
var sysId = gr.getValue('sys_id'); // Sys ID of audited record
var businessContact = gr.getValue('business_contact'); //is not null or blank and user is active
var serviceOwner = gr.getValue('owned_by'); //is not null or blank and user is active
var serviceManager = gr.getValue('managed_by'); //is not null or blank and user is active
var deliveryOwner = gr.getValue('delivery_manager'); //is not null or blank and user is active
var primaryContact = gr.getValue('supported_by'); //is not null or blank and user is active
var primarySPG = gr.getValue('support_group'); //is not null or blank
var platformName = gr.getValue('u_es_organisational_platform'); //is not null or blank
var description = gr.getValue('description'); //at least 15 characters
var approvalGroup = gr.getValue('change_control'); //is not null or blank
var environment = gr.getValue('environment'); //is not null or blank
var arcAvailabilityTier = gr.getValue('u_cba_availability_tier'); //is not null or blank
var arcRecoverabilityTier = gr.getValue('u_cba_arc_recoverability_tier'); //is not null or blank
var arcCyberSecurityTier = gr.getValue('u_cba_cyber_security_tier'); //is not null or blank
var arcOverallTier = gr.getValue('u_cba_overall_tier'); //is not null or blank
var costcenter = gr.getValue('cost_center'); //is not null or blank
var company = gr.getValue('company'); //is not null or blank
var availability = ''; //Service comitment record exists of type 'Availability' and is not empty
// Determine if businessContact not null or blank and user is active
if (!businessContact) {
columnNameSpace = gr.business_contact.getLabel(); // String value of column audited against
// Call log failed result API
// Params:
// auditId - Sys id of audit record executed
// auditedRecordId - Sys id of the record audited
// followOnTask - Sys id of the follow on task associated with the audited record(@see auditedRecordId). Can be empty
// columnDisplayName - Label of the column audited(ex. Disk space (GB)). Can be empty
// operatorLabel - Label of the operator used to audit the column(ex. is not empty, greater than). Can be empty
// desiredValue - Desired value of the column. Can be empty
// discrepancyValue - Discrepancy value. Can be empty
// isCI - True, if audited record is a CI. False, otherwise.
// domainToUse - Sys domain of the "cert_audit" record. Can be empty
new SNC.CertificationProcessing().logAuditResultFail(current.sys_id, sysId, '', columnNameSpace, 'not null', '', gr.getDisplayValue('business_contact'), true);
pass = false;
} else {
//Check user is active
userGr = new GlideRecord('sys_user');
userGr.get(businessContact);
if (userGr.isValidRecord()) {
if (userGr.getValue('active') == 0) {
columnNameSpace = gr.business_contact.getLabel(); // String value of column audited against
new SNC.CertificationProcessing().logAuditResultFail(current.sys_id, sysId, '', columnNameSpace, 'active user', '', gr.getDisplayValue('business_contact'), true);
pass = false;
}
}
}
Any help is much appreciated!
- Labels:
-
Data Acquisition