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

Business Rule condition not working

leachy23
Kilo Expert

Happy Monday all, 

Im trying to get a business rule to trigger when a 'Resolve' UI Action is clicked on a 'parent' ticket within a scoped app, but for some reason it never triggers.

my condition is current.state.changesTo(6)

Its an after business rule (I have tried before) . 

the BR itself is 

function closeRelatedTasks(me) {
var task = new GlideRecord("x_insoa_investec_a_table_caa");
task.addQuery("parent", '=', me.sys_id);
task.query();
while (task.next()) {


gs.print("Task " + task.number + ' closed based on closure of task ' + me.number);
task.state.setValue(6);
task.close_notes.setValue("Resolved by closure of Parent");
task.update();
}


this.closeIncident(me);
}

All help is appreciated!

1 ACCEPTED SOLUTION

leachy23
Kilo Expert

It was a mistake in the the code, I replaced 

gs.info("case " + lend.number + ' closed based on closure of case ' + me.number);

with 

gs.info("case " + lend.number + ' closed based on closure of case ' + current.number);

 

and it all worked fine! Thanks for the replies all

View solution in original post

11 REPLIES 11

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Have you considered using the Condition Builder instead of the condition field?

find_real_file.png

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Hi Mark, 

Thanks for the response, yes that was my first choice but alas it didn't work. 

Can you confirm that the Business Rule is not executed at all? Did you do debugging on this? My guess is it's not an issue with the condition.

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

The reason I didn't think it was working was none of the debug breakpoints were triggered when I changed resolve a ticket to meet the condition, but I've actually just added an info message to the end and its appearing so it must be the script that is nonsense!