web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / Entity form - save bef...
Power Pages
Answered

Entity form - save before before running workflow

(1) ShareShare
ReportReport
Posted on by 36

I have an entity form with a Submit button (as normal). I've added a Workflow button (using the ActionButtonConfiguration section on the AdditonalSettings tab of the EntityForm record). The button is configured to run a specific workflow. All works fine.

 

However, if a portal user opens the form, enters some data and presses the workflow button (but doesn't press the save button) then the workflow runs (as expected) but the form isn't saved, so the workflow doesn't see the new data that the user has entered (because it isn't saved).

 

This is confusing for the user - there's no obvious indication that the form needs to be saved before they can run the workflow.

 

Is there a way to either (a) have the workflow button save the record before running the workflow, or (b) determine if the form is dirty and if so then disable the workflow button?

 

Thanks

Mike

Categories:
I have the same question (0)
  • Verified answer
    oliver.rodrigues Profile Picture
    9,398 Most Valuable Professional on at

    I love this kind of question 😁

     

    I've been playing around here and managed to get a work around. My initial thoughts was using the preventDefault method, however is seems that OOB the Workflow button is already using that.. so we can't prevent what's already being prevented.. so I had to be more creative

     

    My work around is basically injecting a code to the click of the Workflow button, and then removing the data-attr element from the button, which is basically the URL to triggering the Workflow, but of course creating a backup of that attribute.. and then once the form is not dirty, check if that attribute needs to be restored

     

    here is the code I came up with, the check is dirty I will leave it to you, but there seems to be plenty of online examples for this:

     

    $(document).ready(function () {
     var workflowButton = $(".workflow-link.btn-default.btn");
     workflowButton.on("click", function () {
    
     var isDirty = true;// IsFormDirty(); // check if isDirty
     if (isDirty) {
     var dataUrl = workflowButton.attr("data-url");
     if (!!dataUrl) {
     workflowButton.attr("data-url-prevent", dataUrl);
     workflowButton.removeAttr("data-url");
     alert("Please save the record first");
     }
     } else {
     var dataUrl = workflowButton.attr("data-url-prevent");
     if (!!dataUrl) {
     workflowButton.attr("data-url", dataUrl);
     workflowButton.removeAttr("data-url-prevent");
     }
     }
     });
    
    });
    
  • mikefeingold Profile Picture
    36 on at

    Hi Oliver -

     

    Thank for your solution to this. All working well!

     

    For the IsDirty check, I couldn't find any recommended way of doing this for portals (found lots of ways for D365/PowerApps).

     

    We ended up using:

     if ($(".dirty").length > 0)

    However this doesn't feel very elegant. Is there a better way?

     

    Regards

    Mike

  • oliver.rodrigues Profile Picture
    9,398 Most Valuable Professional on at

    I never thought about that, by default there is a dirty class added to controls in the page when they get dirty, so my opinion that solution is good enough

    thanks for that, I will probably use it in the future 😉

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Pages

#1
Suriyanarayanan V Profile Picture

Suriyanarayanan V 45

#2
oliver.rodrigues Profile Picture

oliver.rodrigues 14 Most Valuable Professional

#3
DP_Prabh Profile Picture

DP_Prabh 13

Last 30 days Overall leaderboard