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

Needs to Update SLA

Gaurav Bhatia
Mega Guru

Hello All,

I have one requirement related to SLA. In which I have to add 1 'AND' condition in the SLAs. Since there are 200 SLAs, that is why I did not want to add this condition manually. So, I want to write a fix script or an On Demand schedule job to update those SLAs.

Can anyone have this kind of script with you. If yes then please share that script with me

Thanks..

Regards,

Gaurav

1 ACCEPTED SOLUTION

Replace


gr.start_condition = startCond + ' .and. ' + 'Symptom = Error'


With:


gr.start_condition=gr.start_condition.replace(/\^EQ/,'')


gr.start_condition+='^u_sympton=error^EQ'



Make sure you replace u_sympton with the system name of your Sympton field and the correct value


View solution in original post

5 REPLIES 5

Dave Smith1
ServiceNow Employee
ServiceNow Employee

Can anyone have this kind of script with you. If yes then please share that script with me


Sounds like a simple GlideRecord script, followed by a loop to add a specific condition.   How far have you got with writing it?


Since there are 200 SLAs, that is why I did not want to add this condition manually.


I wouldn't want to, either.... but I'd question why there are so many SLAs.   Do you have 200 OLAs underpinning them also?   This feels like someone's not properly understood Service Level Management as a process.


I have tried to write as below but this does not works.



var query = 'collection=incident^active=true^type=SLA^u_sla_type=Response';


var gr = new GlideRecord('contract_sla');


gr.addEncodedQuery(query);


gr.query();



var rows = gr.getRowCount();


gs.info(rows);



while(gr.next())


{


var startCond = gr.start_condition;


gr.start_condition = startCond + ' .and. ' + 'Symptom = Error'


gr.update();


}


but this does not works.


That's a pretty vague problem definition.   How do you know it doesn't work? What are your test cases? How did expected results differ from actual?   What logging have you implemented, and what do those logs show?


Replace


gr.start_condition = startCond + ' .and. ' + 'Symptom = Error'


With:


gr.start_condition=gr.start_condition.replace(/\^EQ/,'')


gr.start_condition+='^u_sympton=error^EQ'



Make sure you replace u_sympton with the system name of your Sympton field and the correct value