Notifications

585 views

Description

Loading demo data in the Data Certification plugin causes sys_triggers to be created and the demo data instances incorrectly use the script new CertificationTaskCreate().runCerts();. When the triggers for these demo data instances run, it will unexpectedly cause the schedules to run, which will in turn create more instances and tasks.

Steps to Reproduce

 

  1. Install the Data Certification plugin with demo data.

    For more information, see the documentation topic Activate a plugin.

  2. Note the number of certification tasks.

  3. In a background script, run the following code

    var current = new GlideRecord('cert_instance');
    current.get('bb4530139791300000f8d7b8fa297535'); //this is the sys_id of one of the demo data records
    new CertificationTaskCreate().runCerts();

    This will replicate the behavior that happens when the Schedule [sys_trigger] records that are associated with certification instances run.

  4. Look at the number of certification tasks and note that there are now more tasks. Triggers against certification instances should not cause more tasks to be created.

  5. Run the Verify User Lenovo Computers schedule and wait for all of the tasks to generate.

    Note the total number of certification tasks.

  6. Copy the sys ID from the new instance that is created.

  7. In a background script, run the following code, replacing PASTE_CERT_INSTANCE_SYS_ID_HERE with the copied sys ID

    var current = new GlideRecord('cert_instance');
    current.get('PASTE_CERT_INSTANCE_SYS_ID_HERE'); 
    new CertificationTaskCreate().runCerts();

    Look at the number of certification tasks. Notice that no new additional cert tasks were created. This is the expected and desired behavior.

 

Workaround

For every undesired certification schedule:

  1. Load the attached update set into your instance. This update set makes a change to the CertificationTaskCreate Script Include. It will add the following if statement to the beginning of the runCerts function:

     if (this.certDef.getTableName() == 'cert_instance')
    	return; 

    This will prevent any Schedule [sys_triggers] that are associated with certification instances from running, regardless of whether they are demo data or user-generated.

  2. This issue only happens if there are left over certification instances from the demo data. If you would like to remove the demo data, run the following script in a background script, replacing PASTE_SCHEDULE_SYS_ID_HERE with the sys_id of the demo data schedule that you would like to remove. 

    Script

    cleanUpData('PASTE_SCHEDULE_SYS_ID_HERE');
    
    function cleanUpData(certScheduleId) {
    	if (!certScheduleId)
    		return;
    	
    	var instance = new GlideRecord('cert_instance');
    	instance.addQuery('cert_schedule', certScheduleId);
    	instance.query();
    	while(instance.next()) {
    		var task = new GlideRecord('cert_task');
    		task.addQuery('cert_instance', instance.sys_id + '');
    		task.query();
    		while(task.next()) {
    			var taskId = task.sys_id;
    			
    			var certEl = new GlideRecord('cert_element');
    			certEl.addQuery('cert_task', taskId);
    			certEl.query();
    			while(certEl.next()) {
    				certEl.setWorkflow(false);
    				certEl.follow_on_task = '';
    				certEl.update();
    				certEl.deleteRecord();
    			}
    			
    			task.deleteRecord();
    		}
    		
    		var trigger = new GlideRecord('sys_trigger');
    		trigger.addQuery('job_context', 'CONTAINS', 'fcDocumentClass=cert_instance');
    		trigger.addQuery('job_context', 'CONTAINS', 'fcDocumentKey=' + instance.sys_id);
    		trigger.query();
    		trigger.deleteMultiple();
    		
    		instance.deleteRecord();
    	}
    	
    	var trig = new GlideRecord('sys_trigger');
    	trig.addQuery('job_context', 'CONTAINS', 'fcDocumentClass=cert_schedule');
    	trig.addQuery('job_context', 'CONTAINS', 'fcDocumentKey=' + certScheduleId);
    	trig.query();
    	trig.deleteMultiple();
    	
    	var certSchedule = new GlideRecord('cert_schedule');
    	certSchedule.get(certScheduleId);
    	certSchedule.deleteRecord();
    }
    

 


Related Problem: PRB1171743

Seen In

Fuji Patch 12 Hot Fix 1
Fuji Patch 9
Geneva Patch 4

Fixed In

Istanbul Patch 11
Jakarta Patch 5
Kingston
London

Associated Community Threads

There is no data to report.

Article Information

Last Updated:2018-03-26 07:36:30
Published:2017-10-16
sys_remote_update_set_f27d7fda2c710300964f9ddf5fcf0dda.xml