Approve/Reject Buttons on form with Flow

Hi Plumsail!

very happy with your stuff. I have one specific thing for UX of my app I'd like to ask for help with the idea;

How would you approach;
Approve/Reject button with Comment, If Reject, comment mandatory - with Flow/Power Automate Approval running on the item on Plumsail Form.

Scenario;

  1. Main item is created
  2. Flow is run on main item which creates multiple new Approval items in the custom list
  3. The list has Flow on new item created and starts Flow Approval Action
  4. User can approve from Flow, E-mail - how to let the user to approve from the item?

Any recommendations? I didn't seem to find any similar post in the community but please feel free to link me to right topic.

thanks!

Hello @karol,

You can add to buttons, Approve and Reject, to the form and add the script to the Settings >> OnClick.
image

So that when Approve/Reject button is clicked, the status of the item changed to approved/rejected and saved the item. For Approve button the script will be the following:

fd.field('Status').value = 'approved';
fd.save();

And to make Comment field required when the item is rejected you need to add custom validator. Please use the following code in JavaScript Editor.

fd.spRendered(function() {  

fd.validators.push({
        name: 'CommentFieldValidation',
        error: "Comment field is required",
        validate: function(value) {
            if (fd.field('Status').value == '12345' && fd.field('Comment').value == '') {
                        return false;
                    }
            return true;
         }
});

});
1 Like

is there a way to check the validation in button click instead of presave. i need some button just to save as draft without checking validation and some button check if field is null. Thank you

i figured it out moving the validation code to button click worked. Thank you.

1 Like

there is one but where setting field on button click is not working in ie explorer most of our user have ie explorer is it known issue? if so is there a workaround for that? Thank you.

@ShantiBhattarai,

Please use the below code in OnClick to save the form in Internet Explorer.

fd.field('Status').value = 'approved';
fd._vue.$nextTick(function() { fd.save(); });
1 Like

it worked with only with ie 11

@ShantiBhattarai,

What version of Internet Explorer are you using?

the issue was old form caching clearing the cache helped. Thank you.

1 Like

It seems like this solution doesn't integrate with the flow approval. Is that correct?

Hello @Amys_Turtlgal,

Which integration do you mean? Could you please give an example.

Well, I mean that your solution seems to set a field to approved or rejected, but doesn't necessarily mention the Approval flow that is mentioned in the original question.

  1. Main item is created
    2. Flow is run on main item which creates multiple new Approval items in the custom list
  2. The list has Flow on new item created and starts Flow Approval Action
  3. User can approve from Flow, E-mail - how to let the user to approve from the item?

So while the the button sets the status and saves the form, it doesn't necessarily complete the Approval Flow automation correct?

Hello @Amys_Turtlgal,

If we are talking about SharePoint Online and 'Start and wait for an approval' action in Power Automate (MS Flow), then the approval buttons are available only in the email notification, and they are not integrated into default Sharepoint forms and Plumsail Forms.

image