simple after business rule not working

juan9
Giga Guru

Im not sure what i am doing wrong haha.

when a record is created, and there is a after business rule that sets active to false, it does not work for some reason:

Screenshot 2024-08-17 at 8.48.36 AM.png

Screenshot 2024-08-17 at 8.49.49 AM.png



if i set the business rule to before it works.

 

here is a small video:
https://youtu.be/spq_8dQsuUA


if the rule was working when is set to after, would i get the updated record or would i have to refresh the page to see the updated record?

Uploaded by Juan Casas on 2024-08-17.
1 ACCEPTED SOLUTION

Yes thats the expected behavior, because you should not do this after, you should do this before.

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

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

LinkedIn

View solution in original post

6 REPLIES 6

Mark Roethof
Tera Patron
Tera Patron

Hi there,

 

What would be your reason to do this after instead of before? If its an update on the current record (which it looks like reading your question), then doing this after does not immediately make sense.

 

Why is the after not working? Because there is no current.update(). Which obviously is a bad practice to do in business rule 😀.

 

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 replying to my question.
Im just seeing if there is something wrong with the instance, doing a simple test is all.

the after is not working because it should be setting active to false after the record is inserted.

I am using the business rules 'actions' so i dont need to use current.update().

the business rule 'action' worked for where i used when=before, so i know i dont need to use current.update() i think.

 

isnt the expected behavior to set active to false?

As I mentioned, no thats not the behavior. Also, why do you want to do an after business rule, doesn't make sense. Please explain.

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

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

LinkedIn

What is the expected behavior? to not work?

I read what you send, it just said it does not work for setting values when using after..... 

i wonder why.

the reason why i am doing this is because i though there was an issue with our system, i was just testing