Redirect/Remain on the same page after update

Sandhya23
Tera Guru

Hi All,

 

Here is the scenario: 

1. Open the problem record to be updated

2. Open the incident record (for some random reason)

3. Update the problem record which would give me the expected error message.

4. The error message is expected to be on the problem record itself but it is opening on the incident record which I previously opened.

 

How can I make sure that the error message is shown in the problem record and not the other record? 

I can not use the SetRedirectURL method here as it is a Business Rule on the background which is giving the error. How can I achieve this?

 

5 REPLIES 5

Abhit
Tera Guru

Hi @Sandhya23  , This is expected behavior,

Update Action: Save's the record and redirects to previous screen (usually a list or last opened page)

Save Action: Save's the record and stay on the same screen.

In the Update UI action on the problem table you can add the below line(Its not recommended since it deviates from OOTB)

action.setReturnURL(current);

Or Update the Button label to more user friendly with how button will respond post click,
 
Cheers!!

I need to correct myself regarding step 3:

  1. Update the required fields on the problem record and right-click to save it. This action gives me the expected result, but the error message is displayed on the incident form (which was opened earlier) instead of the problem form.

Below is the code snippet for reference. Could you please help me ensure that the problem record remains open when saved, and prevent it from redirecting to the incident record (opened just before updating the problem record)?

 

Sandhya23_0-1716810471362.png

 

 

@Sandhya23  add the below code in the BR

current.setAbortAction(true);
var redirectUrl = gs.getProperty('glide.servlet.uri') + '/problem.do?sys_id='+current.getValue('sys_id');
gs.setRedirect(redirectUrl);
gs.addErrorMessage(gs.getMessage("Add your error message here"));

 

Hi Abhit,

 

It is still not working. When I checked my system property I donot find the record for 

'glide.servlet.uri'

 Are we supposed to create this property? And will it not vary form instance to instance ?

 

For testing purpose, I hardcoded the value by replacing it with the Base line URL for the ServiceNow instance in my Business rule, it still did not work. it directed me to the previously saved Business Rule with the error message at the top.