Don't allow a request to be submitted based on a certain value in a field.

chenelle
Kilo Expert

Does anyone have a script for not allowing a request to be submitted if they have a certain value in a selectbox or multiple choice selected?   So that the request don't go any where or "Order now" can't be submitted unless they change the value to the option in the selectbox or multiple choice that will allow them to submit the request or they cancel the request due to their answers not qualifying the request to be submitted.   For example there are two options in a drop down list:

<20

> 20

If the user selects <20, they can't submit the request and will need to cancel it.

If they select >20 then they can select the request.

Please advise if you can.

Thanks

Chenelle

1 ACCEPTED SOLUTION

parameswar
ServiceNow Employee
ServiceNow Employee

Hi,


You can write onSubmit client script on catalog item.


Go to item -> right click on catalog item header -> click on configure item


SS0.jpg


Then go to Catalog Client scripts tab


SS3.jpg


Then click on 'New' the write onSubmit client script as below


SS1.jpg


Now try to click on 'Order now'. Now you can see alert and form will not submit


SS2.jpg


View solution in original post

5 REPLIES 5

parameswar
ServiceNow Employee
ServiceNow Employee

Hi,


You can write onSubmit client script on catalog item.


Go to item -> right click on catalog item header -> click on configure item


SS0.jpg


Then go to Catalog Client scripts tab


SS3.jpg


Then click on 'New' the write onSubmit client script as below


SS1.jpg


Now try to click on 'Order now'. Now you can see alert and form will not submit


SS2.jpg


Thank you Parmeswar!   That worked for the alert on submit, however, after I clicked ok on the alert message, and then clicked "Order Now" I was still able to submit my ticket.   I want it to just spin and never submit if it is less than 20.   I know that can be done as i did it in the past with another developer but i totally forgot the script for it.   Please help if you can.  


parameswar
ServiceNow Employee
ServiceNow Employee

Please make sure that you return false after alert.


Thank you for your help.   The script you gave me does work.   However, the other option which is more than 20 wont submit either.



So I have the multiple choice as below and the less or more option does as it should and doesn't move forward with the request if I click order now.   However when I select 20 or more, it does not move forward either. The script is only for Less than 20 <20.   So i don't know why it doesn't work.   See the script below too.   Do you know why it isn't working correctly when I select 20 or more?       Thanks!



find_real_file.png



find_real_file.png