Business Rule not working as expected for Availability Rating in CIA Assessment.

B Swethana
Tera Contributor

We have a requirement to create a new Plan in the BCM module (sn_bcp_plan) under specific conditions when a 'Confidentiality, Integrity and Availability Assessment' request is submitted.

The specific conditions are:

  1. Operational State is 'Operational'.
  2. Availability changes to 4 - Critical or 5 - Critical.
  3. Classification is 'Application Service', 'Technical Service', 'Hosting Service', or 'Network Service'.
  4. There is no current plan available for the Service.

I have created an after business rule on the 'service_process_task' table with the following conditions under When to run:

  • State changes to Closed Complete.
  • Request type is CIA Assessment.
  • Service.Operational status is Operational.
  • Service.Service Classification is one of 'Application Service', 'Technical Service', 'Hosting Service', 'Network Service'.

Here is the code in the Advanced tab of my business rule:

 

(function executeRule(current, previous /*null when async*/ ) {
var serviceProcessTask = new GlideRecord('service_process_task');
serviceProcessTask.addEncodedQuery('business_service.u_asmt_availability=4^ORbusiness_service.u_asmt_availability=5);
serviceProcessTask.query();

while (serviceProcessTask.next()) {
var ciatask = new GlideRecord('sn_bcp_plan');
var service = current.business_service.getDisplayValue();
var finalservice = service + ' - SCPlan ';
ciatask.addQuery('name', finalservice);
ciatask.query();
if (ciatask.next()) {
ciatask.setAbortAction(true);
} else {
gs.log('Availability for ' + finalservice + ': ' + serviceProcessTask.business_service.u_asmt_availability);
var template = new GlideRecord('sn_bcp_template');
template.addQuery('name', 'Service Continuity Plan (SCPlan)');
template.query();

if (template.next()) {
var templateSysId = template.sys_id;
ciatask.initialize(); 
ciatask.name = finalservice;
ciatask.template = templateSysId;
ciatask.plan_owner = current.assigned_to.getDisplayValue();
ciatask.type = 'Continuity Plan';
ciatask.insert();
}
}
}
})(current, previous);

 

The issue is that the business rule is creating records in 'sn_bcp_plan' table regardless of the availability value. The log statement

 gs.log('Availability for ' + finalservice + ': ' + serviceProcessTask.business_service.u_asmt_availability);

 shows an availability value of '4' for every service, even if the actual values are 0, 1, 2, 3, 4, or 5.

Could anyone help me understand why the availability value is not filtering correctly and how I can fix this issue?

 

Thanks in advance!

0 REPLIES 0