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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Unanswered

How to write a script on webform step to save the form? #portal #crm #d365 #dynamics365

(0) ShareShare
ReportReport
Posted on by

I have written below on my custom button, This code is not working.

$(document).ready(function () {    

    var saveButton = $('<input/>').attr({ type: 'button', name: 'ctl00$ContentContainer$MainContent$EntityFormControl$UpdateButton', value: 'Save', id: 'btnSaveValidate', class: 'btn btn-primary button next submit-btn' });

    $("#NextButton").after(saveButton);

    $("#btnSaveValidate").bind("click", function () { 

        WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$ContentContainer$MainContent$EntityFormControl$UpdateButton", "", true, "", "", false, true));

      

    });

});

I have the same question (0)
  • cloflyMao Profile Picture
    25,210 on at

    Hi Bhavika,

    Please take article below as reference:

    https://docs.microsoft.com/en-us/powerapps/maker/portals/configure/add-custom-javascript#general-validation

    On click of the Next/Submit button, a function named webFormClientValidate is executed. You can extend this method to add custom validation logic.

    Regards,

    Clofly

  • Community Member Profile Picture
    on at

    Hi,

    But how should I trigger the save event in webform step?

    Currently I have added a custom button and on click of it I am trying to trigger SAVE event should trigger.

    So I use- WebForm_DoPostBackWithOptions function to trigger it but somehow It doesn't saves the changes on form step  

  • cloflyMao Profile Picture
    25,210 on at

    Hi Partner,

    Copy all content of "onclick" attribute of the default submit button by javascript to your custom button test whether it could work.

    5707.pastedimage1589354472894v1.png

    Regards,

    Clofly

  • Community Member Profile Picture
    on at

    Hi Clofly Mao,

    Default submit and Next functionality (of webform step) both calls the same function

    WebForm_PostBackOptions("ctl00$ctl00$ContentContainer$MainContent$EntityControls$WebFormControl$NextButton", "", true, "", "", false, true))

    However If I use the above functionality my form gets saved and it moves to another step, But i want it to just the save the record and stay on the page

    Thanks

  • cloflyMao Profile Picture
    25,210 on at

    Hi Bhavika,

    I have tested WebForm_PostBackOptions function in my portal for you, but unfortunatedly I didn't find a way to customize it, it seems that logic of the function is complex.

    My suggestion is that you might still need to use default next/submit button and do validation with webFormClientValidate function,

    you could apply custom css to overwrite the default button and change it to appearance of your custom button.

    Regards,

    Clofly

  • Charlie Chen Profile Picture
    92 on at
    Hi cloflyMao, The link of Microsoft doesn't seem to work. I deploy the code to the web page hosting the multi-step form and the form step both, the code was invoke when the page is loaded. But when the button is clicked, no custom logic was invoked.
     
    if (window.jQuery) {
        (function ($) {
            debugger;//page
           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.
     
                    var userConfirmed = confirm("Are you sure you want to submit the form?");
           console.log("User confirmed: " + userConfirmed); // Debugging output
           
             if (!userConfirmed) {
                return false;
             }
                    return true;
                 };
              }
           }
        }(window.jQuery));
     }

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 81 Super User 2025 Season 2

#2
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 49 Most Valuable Professional

#3
#ManoVerse Profile Picture

#ManoVerse 40

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans