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

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / Power Pages Form Butto...
Power Pages
Unanswered

Power Pages Form Button - JS Button Events

(0) ShareShare
ReportReport
Posted on by 2,429 Super User 2025 Season 2

Hello everyone,

 

I cam across a confusing problem.

As I wanted to save a variable when the submit button on a form is pressed, I could not find a event type working.

I tried the button.onSubmit() and button.onClick() after using a JQuery selector to store the Element inside it.

 

Is there a way to get the triggerevent of a button in a form? I usually take the id of the element if possible:

Lucas001_1-1686659163637.png

 

 

Lucas001_0-1686659087675.png

 

Categories:
I have the same question (0)
  • Saud Ali Profile Picture
    812 Super User 2024 Season 1 on at
    Re: Power Pages Form Button - JS Button Events

    Hi @Lucas001 ,

     

    I'm unsure, what is your actual use case but generally whenever we have to do some sort of validation etc. on form submission, we do by using jQuery. You can navigate to Additional setting if you're using a Basic Form and put your script there.

    Here is the sample script for reference:

    if (window.jQuery) {
    (function ($) {
    if (typeof (entityFormClientValidate) != 'undefined') {
    var originalValidationFunction = entityFormClientValidate;
    if (originalValidationFunction && typeof (originalValidationFunction) == "function") {
    entityFormClientValidate = function() {
    originalValidationFunction.apply(this, arguments);
    // do your custom validation here
    // return false; // to prevent the form submit you need to return false
    // end custom validation.
    return true;
    };
    }
    }
    }(window.jQuery));
    }

     

    If you have added a custom button on form, then you can capture events by jQuery as well.

     

    Please mark as verified if the answer is helpful.

     

    Thanks

  • Verified answer
    Fubar Profile Picture
    8,319 Super User 2025 Season 2 on at
    Re: Power Pages Form Button - JS Button Events

    Similar to the post above from saudali.  It may depend on exactly what you are trying to do (e.g. if you needed to capture the User making the submission you would use form Metadata and not something on the Submit, similarly some values you may set on create/change using a Workflow or Plugin code).

    When the Submit button is pressed the form will call a Validator, that you can add your own validations to (so this is one place that you know the submit button has been pressed and may be able to add what you want in there).

    https://learn.microsoft.com/en-us/power-pages/configure/add-custom-javascript#additional-client-side-field-validation

     

  • Lucas001 Profile Picture
    2,429 Super User 2025 Season 2 on at
    Re: Power Pages Form Button - JS Button Events

    Thanks @Fubar and @saudali_25,

     

    to specify my problem a bit more. I have a oracledatabase as backend which needs to check the account data of the newly registered people. So that they are not allowed to make specific actions. They receive a mail and so but I also want to display a message on the profil form which tells the client that their data is currently being processed. Usually a flag is than send and javascript does the rest. Sometimes however the flow or the connection between dataverse and the power page seems to be slow or not fast enough, so that the message is not displayed.

     

    As it is the profile web form which is displayed, I cannot access it via the portal management system. Do you have another solution where I could place Javascript in? To get the click or onSubmit when I write JavaScript into the site itself, is not working on my site.

  • Saud Ali Profile Picture
    812 Super User 2024 Season 1 on at
    Re: Power Pages Form Button - JS Button Events

    Hi @Lucas001 ,

     

    I had to experience similar scenario in the past where I had to show an extra button to do some Api calls with external system. Here is the way how you can add an additional button on Portal profile page and give you control to run your script.

     

    1- Go to Web Pages

    2- Open Profile -> Content Page

    3- Advance -> Add script

    $(document ).ready(function() {
    
     $('#ContentContainer_MainContent_MainContent_ContentBottom_SubmitButton').after('<input type="button" value="Sync With Oracle" onclick="javascript&colon;clearIsDirty();disableButtons();window.history.back();" id="CancelButton" class="btn btn-primary"/>')
    
    });

    Here are the results:

    saudali_25_0-1686752009868.png

     

    Thanks,

    Saud

     

    Please mark as verified if the answer is helpful.

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Pages

#1
Jerry-IN Profile Picture

Jerry-IN 66

#2
Fubar Profile Picture

Fubar 45 Super User 2025 Season 2

#3
Michael E. Gernaey Profile Picture

Michael E. Gernaey 31 Super User 2025 Season 2

Last 30 days Overall leaderboard