You are viewing limited content. For full access, please sign in.

Question

Question

Easiest Way to Reject a Form While Missing Some Required Fields

asked on August 12

I'm curious how other users are managing use cases like this.

Owner of the process I'm creating wants an approver to be able to click a "Reject" action button on the form to return it to an earlier stage in the process.  But they want to do it without filling in a dozen required fields on the form (basically make them required when submitting but not when rejecting).

I know I could do this with Field rules and a checkbox/radio button/etc. to make the decision - but they really want it to be with the submission buttons.

I handled this on the Classic Designer by having Javascript remove the required attribute from the fields when the Reject button was clicked, and they are wanting that same functionality in the Layout Designer.

Any suggestions or tricks that people have learned to make this kind of thing work in the Layout Designer?

0 0

Answer

SELECTED ANSWER
replied on August 21 Show version history

I found an option that works (sort of).

I made a hidden field on my form.  I named it "user_submit_action".  Via Field Rules, it is hidden Always, and ignores data when hidden.

Then I have Javascript update the value in the user_submit_action field when the user presses a submission button.

Finally, I have Field Rule(s) that act on every single field that is required.  They set the fields to optional when the user_submit_action = Reject.

The result is the user presses any submission button, the Javascript populates the user_submit_action field with the value for that submission button.  If that value is Reject, the various required fields are changed to optional, and then the submission processes like that.  In my testing on Version 12.0.2503.10378, it worked as expected.

And since the Field rules is set to ignore the value when hidden, it doesn't save upon submission and thus future tasks all start with a clean slate in the user_submit_action field.

Here's the Javascript: 

//Add the submit action to the user_submit_action field on submission.
LFForm.onFormSubmission(async function (event) {
  await LFForm.setFieldValues({variableName: "user_submit_action"}, event.data.action.value);
});

 

5 0
replied on August 21

Very nice! I've done something like this in the Classic Designer, but I didn't even think to try it in the modern designer.

1 0

Replies

replied on August 12

You can use a radio button to select your approve/reject decision instead of using a submit button for it. This way, you can conditionally require fields only when approve is selected.

3 0
replied on August 13

Yeah, I think that might end up being the way to go.  Thank you.

0 0
replied on August 12 Show version history

I usually handle this by creating my own Approve/Reject radio buttons with a single Submit button.

Then, I set field rules based on the radio buttons.

2 0
replied on August 13

Yeah, I think that might end up being the way to go.  Thank you.

0 0
replied on August 21

What Jason said is how we handle it as well. I've had discussions with the Forms team about being able to do this when selecting an Action button, as well as making the built in Task Comment box required based on what action button is selected. Hopefully someday.

1 0
replied on August 21

This is already marked as solved, but I'll just add that I feel this pain.

We also used JS to remove the required attribute in the Classic Designer, and it was a much cleaner solution. I don't love depending on radio buttons to select approve/reject before clicking Submit, and that feels much more like a workaround than a step forward.

Hopefully, the ability to suppress the required attribute on button click is added back in future releases!

2 0
replied on August 12

Generally what I do in these use cases are to only enable the approve button if all the fields are completed while reject has none such requirements. We then add a note to said fields that must be completed before Approval is allowed. It is not as clean since it is harder to tell required fields, but does fit the use case. 

1 0
replied on August 12

That might work for some use cases.  Thank you.

0 0
replied on August 12

Have you taken a look at using Process Stages in your process?  I use them along with field rules to enforce the field being optional for operations in that Process Stage.

 

1 0
replied on August 12

I've done that in multiple cases - but I don't think it will work here where I have a form that is being considered by a user for approval or rejection (with rejection being to return it to the prior user).  With approval, we need to make sure the user has populated those fields, but with rejection they don't have to.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.