cancel
Showing results for 
Search instead for 
Did you mean: 
Workflow Hero

Using Validation rule to enforce fields depending on a button

Jump to solution

Hi,

As per the subject I am trying to enforce some fields (make them mandatory) using the new Forms Validation rules, but IF the user click a different button (ie Save as Draft, which set a field value to 0) then I don't want any of these validation to happen.

 

So I am happy to have a rule such as

and( greaterThan({ItemPropertySmiley Frustratedtage}, 0) , isNullOrEmpty({Self}))

--> if this is TRUE it will force the field ({self} to be filled.

 

But the issue is that [Stage] is a field and not a control in the form, so the value is not understand yet UNTIL the form is saved. Therefore rule will not work.

Also we cannot have a Rule Validation that is using a Control in the form.... kind of a closed circle :-(

 

any idea how to make fields mandatory depending on a button being pressed ? (thought I woudl use the new Rue, but may revert to JS in the end?)

 

many thanks community people :-)

Labels: (2)
Tags (3)
0 Kudos
Reply
6 Replies
Workflow Hero

Re: Using Validation rule to enforce fields depending on a button

Jump to solution

Hi Francois,

 

You won't be able to achieve this by using Rules. You will have to use JavaScript to do this.

 

Just add your JavaScript function into form setting and use that function name into client click property of button control settings.

 

Please let me know how you go.

 

Regards,

Shirin

0 Kudos
Reply
Workflow Hero

Re: Using Validation rule to enforce fields depending on a button

Jump to solution

Sorry I didn't respond, yes I did the whole checking of fields in Javascript.

I am now having an issue to just SUBMIT the form,  at the end of the Field Valdiation I am just passing a Submit(); and it doesn't save.

I can't find the right trigger, any tip here please?

0 Kudos
Reply
Workflow Hero

Re: Using Validation rule to enforce fields depending on a button

Jump to solution

Hi Francois,

Can you please try to return true, please make sure your button action is pointing to "Save and Submit"?

Let me know how you go.

Shirin

0 Kudos
Reply
Workflow Hero

Re: Using Validation rule to enforce fields depending on a button

Jump to solution

Hi,

Yes button is Save&Submit (not just Save) and the Javascript is calling a function like CheckAllFields();

within the CheckAllFields() I end the function with return true;

and the form actually refreshes but stays open (and no save in the background)

:-(

0 Kudos
Reply
Workflow Hero

Re: Using Validation rule to enforce fields depending on a button

Jump to solution

FInally managed to do it after many tests, the correct code in "Client Click" of that button should be

if( myfunction() == true) { return true; }  else { return false; }

and this way of evaluating the return value from the function, the button know what to do next.

0 Kudos
Reply
Workflow Hero

Re: Using Validation rule to enforce fields depending on a button

Jump to solution

In response to my own question a few weeks ago, I have finally managed to take the time and write the steps I used to include Field Validation in Javascript depending on the type of field to check the value.

Here is the link, it may be useful for somebody

Nintex Forms and Validation rules: a good feature added, but not so great yet for validating fields,...

Reply