UI action form button to appear when all mandatory fields are filled

davilu
Mega Sage

Hi Everyone, I've never created an UI Action before and am a bit confused on how to go about scripting it.  I want a new Form Button to appear when all the mandatory fields of the form have been completed.  Our form has a rather large number of mandatory fields (20+); is there a way to efficiently code this in one or two lines of code instead of listing out every mandatory field to check if it isn't blank?

For example, I know we can write a condition that looks something like this:

current.my_variable1 != ' ' || current.my_variable2 != ' ' || current.my_variable3 != ' ' || ... current.my_variable20 != ' ';

find_real_file.png

 

However, we're hoping to condense this down to just 1-2 lines of script.

 

Any help is appreciated.  Thanks!

4 REPLIES 4

Mrigank Gupta
Giga Expert

What is the actual requirement that you want to fulfil from the UI action?

There is no need to hide the UI action button just to ensure that user is filling all mandatory fields or not.

Servicenow platform, checks data in all the mandatory fields on the form before user clicks on any button. It will be automatically taken care if you are settint the field mandatory through a client script or UI policy.

ahh good point.  Our team wants the button to be disabled or hidden until all mandatory fields are completed, is this possible to do?

 

As for what the button will actually do...we're hoping to link the button click to trigger a Lifecycle Event Activity, do you know if this is possible as well?

Shubham47
Tera Expert

Facing same issue, any solution?

I am also looking for a solution here.