How to reload a form using Business rule ?

Vijay Kumar21
Tera Contributor

Hi Team,

I need to reload a form when the code is executed in the Before - Bussines rule.

Do we have any syntax which we can use to reload the form in the business rule?

 

2 REPLIES 2

Gaurav Rotke1
Kilo Guru

Hi Vinay Kumar,

Use this;

gs.setRedirect (current.getLink(true));

but I think you should use it with after BR.

Please mark correct and helpful.

Thank you

Gaurav Rotke

Ethan Davies
Mega Sage
Mega Sage

Hi Vijay,

What is the use case for this? When you use the Save UI Action in ServiceNow you will remain on the updated form, we do not need to code something in a Business Rule to do this. I would not recommend putting a redirect in a before BR because Business Rules can be triggered by all sorts of things such as other records causing an update, integrations etc.

find_real_file.png

If you have to put a redirect in you can use the below code. My recommendation in that case would be that make sure that the Business Rule only fires when the session is an interactive one (i.e a user triggered event) as this will cause you less pain and unexpected behaviours in the long run.

// Set it to the link for the current record, or you could replace this with a URL string if you wanted to go somewhere else.
var redirectLink = current.getLink(true)
gs.setRedirect(redirectLink);

The code for checking if a session is interactive is:

find_real_file.png

Thanks,

Ethan

Please mark correct and helpful if my reply solved your issue.