Prevent catalog form to redirect into a new URL from service portal

Sajal Chatterje
Tera Contributor

Hello Community,

 

I did some validation for catalog from using client script and script include and its is throwing some validation message as expected but the issue is although its showing message It is redirecting to different URL on submitting the form.

 

How can we prevent it from navigating to different URL and force it to stay on the same catalog form page where the validation message was shown from service portal. I used return statement but still its redirecting to a different url .Kindly help here.

 

It is taking me to the ritm window.I deally I want to stay on the same form .

SajalChatterje_0-1721745864191.png

 


        if (answer == "true") {
            g_form.addErrorMessage("There is already an existing delegation for this user and delegate with the same delegated items within the same time period.");
           
            return;
        }

 

3 REPLIES 3

Astik Thombare
Tera Sage

Hi @Sajal Chatterje ,

 

 In the record producer script you can use portal_redirect to redirect to a specific service portal page.

 

 

producer.portal_redirect = "sp?id=sc_home"

 

 

For more information, please refer to https://docs.servicenow.com/bundle/washingtondc-servicenow-platform/page/product/service-catalog-man...

 
 
If my reply helped with your issue please mark helpful 👍 and correct ✔️ if your issue is resolved.

By doing so you help other community members find resolved questions which may relate to an issue they're having


Thanks,

Astik

Hello @Astik Thombare ,

 

The form that I'm using is not  a record producer. It is a service request having approvals, task etc. Let me know how it is going to work in that case.

 

Thanks!

Markus Kraus
Kilo Sage

I think what you actually need is asynchronous validation:

If the validation fails, show an error message and stay on the form. You simply need to "return false;" instead of "return;".

Let us know if you need help with the asynchronous part.