BR - to change acknowledged value as true on on-call escalation table if incident is assigned.

SakshiBagal
Tera Contributor

I have written business rule  to change acknowledged value as true on on-call scheduling table if incident is assigned. But it is not working, can someone help me to resolve it.

Table- Incident

When- After Update 

Condition- Assigned to is Not Empty

 

 

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

var gr = new GlideRecord('on_call_escalation');

gr.addQuery('source',current.sys_id);

gr.query();

while(gr.next())

{

    gr.acknowledged=true;

    gr.update();

}

 

I have already deactived OOB ACL which allows  users with maint role  to write operation on on-call escalation table.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@SakshiBagal 

ACL won't come into picture as you are using GlideRecord and not GlideRecordSecure.

Your BR condition should be this

Assigned To [Changes] AND Assigned to [IS NOT EMPTY]

Things to check

1) did you add log and see if query ran?

2) are you using correct source field to query and correct acknowledge field?

var gr = new GlideRecord('on_call_escalation');
gr.addQuery('source', current.sys_id);
gr.query();
while (gr.next()) {
    gs.info('Record found');
    gr.acknowledged = true;
    gr.update();
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

3 REPLIES 3

Chaitanya ILCR
Kilo Patron

Hi @SakshiBagal ,

 

create a new ACL(write and read(if already doesn't have)) or reactivate the ACL and give a role(ITIL or any relevant role) and try

 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

I have added log in script and it is showing source value as undefined.

Ankur Bawiskar
Tera Patron
Tera Patron

@SakshiBagal 

ACL won't come into picture as you are using GlideRecord and not GlideRecordSecure.

Your BR condition should be this

Assigned To [Changes] AND Assigned to [IS NOT EMPTY]

Things to check

1) did you add log and see if query ran?

2) are you using correct source field to query and correct acknowledge field?

var gr = new GlideRecord('on_call_escalation');
gr.addQuery('source', current.sys_id);
gr.query();
while (gr.next()) {
    gs.info('Record found');
    gr.acknowledged = true;
    gr.update();
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader