Validating certain fields in a form when a user clicks a form button

karanchawla2002
Kilo Explorer

I am working on a change ticket form with two form buttons which are "Submit" and "Request Approval". Submit is a way of inserting the record in the table.However the ticket will only move forward when the user presses "Request Approval".

 

I want to impose certain restrictions ONLY when a user clicks on "Request Approval" . By restrictions I meaning prompting the user to fill the Planned Start Date , End Date. However no such message should appear when a user clicks on Submit.


One way of doing it is to put in a condition for visiblity through a UI action. But I want the button to visible at all times. Please help

5 REPLIES 5

Brad Tilton
ServiceNow Employee
ServiceNow Employee

You could run a client side check in the Request Approval ui action to make sure those fields have values, and then submit the form.


» How to Execute Client Script and Business Rule Script in One UI Action


Thanks for the reply !! Executing partially on client and partially on server always help. The validation is working But for some reason when I go ahead with request approval , I get an "Actional NOT authorized " error message. I guess that usually happens when you there is a discrepancy in the conditions. I cant figure out any issue here:



code.JPG


"Action not authorized" sounds like you click the UI Action using the list view and not the form view, correct?


If that is the case, then the condition of the UI Action is not satisfied.


Greetings,



Make sure you have giving some name to UI Action and calling the same in script


    gsftSubmit(null, g_form.getFormElement(), '<button_action_name>'); //MUST call the 'Action name' set in this UI Action



Let me know if that's work for you.



Regards,



Solutioner


Logo.png


Enhance Knowledge NOW@ www.solutioningnow.com