The CreatorCon Call for Content is officially open! Get started here.

Piotr Ba_amut
Giga Expert

Use Case: 

It may happen that you would like to create any SLA or OLA automatically when, let's say any group is created (to automate the process of Service Level Mgmt definition). 

For doing a case above, there might be useful to create a business rule on the sys_user_group table with the glide query on the contract_sla table. 

Specification: 

When: After

Insert: True

Advanced: True

In such a scripted business rule the most important is how to appropriately refer to Start conditionsNamely, it requires providing the string "collection=table_name". 

Exemplary code may look like : 

 

(function executeRule(current, previous /*null when async*/) {

	var ola = new GlideRecord('contract_sla');


	 ola.initialize();
	 ola.name = "P1 " + current.name + " for all incs with Priority = 1"; //is setting contract name
	 ola.target = 'Resolution';
	 ola.setValue('start_condition','priority=1^assignment_group=Service Desk^EQ^collection=incident'); //is setting OLA conditions
	 ola.type = 'OLA';
	 ola.setValue('duration',gs.getDurationDate('0 1:0:0'));  //is setting OLA duration
	 ola.schedule = '8-5 weekdays'; //OLA schedule
	 ola.insert();
	

 

 

 Then, once you create a new group, it will automatically create a new OLA definition like this: 

 

find_real_file.png

Version history
Last update:
‎08-03-2018 01:13 AM
Updated by: