Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

onSubmit() question for form

PhFranca
Tera Expert

Hello everyone! I am creating an app for educational purposes. After several searches over the last few years, I have not been able to find the solution.

When I click on the Submit button, I would like it to open a warning message like "Your request has been submitted successfully" and return to the home page.

Can anyone help me and teach me how to do this?

Thank you very much!

2 ACCEPTED SOLUTIONS

Satishkumar B
Giga Sage
Giga Sage

@PhFranca you can write a catalog client script for this. :

 

 

function onSubmit() {
    alert("Your request has been submitted successfully");
    top.window.location= '/sp';  
}

 

…………………………………………........................................................................................
Mark it helpful 👍and Accept Solution !! If this helps you to understand.

…………………………………………........................................................................................

View solution in original post

Hemanth M1
Giga Sage
Giga Sage

Hi @PhFranca 

 

Seems like you built a catalog item,

 

The easy way to so this, Write a onsubmit catalog client scrript and add below logic 

 

 

HemanthM1_1-1723134032023.png

 

Replace with your portal if its different.

HemanthM1_3-1723135035436.png

 

Output:

 

HemanthM1_4-1723135088564.png

 

Redirect to home page:

 

HemanthM1_5-1723135148152.png

 

 

Hope this helps!!

 

 

 

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

View solution in original post

4 REPLIES 4

Satishkumar B
Giga Sage
Giga Sage

@PhFranca you can write a catalog client script for this. :

 

 

function onSubmit() {
    alert("Your request has been submitted successfully");
    top.window.location= '/sp';  
}

 

…………………………………………........................................................................................
Mark it helpful 👍and Accept Solution !! If this helps you to understand.

…………………………………………........................................................................................

Hemanth M1
Giga Sage
Giga Sage

Hi @PhFranca 

 

Seems like you built a catalog item,

 

The easy way to so this, Write a onsubmit catalog client scrript and add below logic 

 

 

HemanthM1_1-1723134032023.png

 

Replace with your portal if its different.

HemanthM1_3-1723135035436.png

 

Output:

 

HemanthM1_4-1723135088564.png

 

Redirect to home page:

 

HemanthM1_5-1723135148152.png

 

 

Hope this helps!!

 

 

 

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

@Hemanth M1 !

Thank you very much! It worked great!

Phlavio

PhFranca
Tera Expert

Hello, @Satishkumar B 

I think I'm doing something wrong. It still doesn't work. Can you help me understand?
Attached is the form in which I created the catalog client script.

Thanks
Phlavio