cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
shahriat
Helper I
Helper I

How to stop page refresh or redirecting while submitting webform?

I have a created a webform for account entity with some steps.

 

In the last step while submitting the form I have ajax code to add a record for my custom entity with account id. 

 

The ajax request is failing because of page refreshing. I want to stop the page refresh or page redirecting until my custom entity's record is saving. 

 

I have added following code:

 

if (window.jQuery) { (function ($) { if (typeof (webFormClientValidate) != 'undefined') { var originalValidationFunction = webFormClientValidate; if (originalValidationFunction && typeof (originalValidationFunction) == "function") { webFormClientValidate = 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)); }

 

I have added the above code in my last step as custom JavaScript but code doesn't work because webFormClientValidate is getting undefined. Wherever I place this code webFormClientValidate getting undefined. 

 

any suggestion?

 

1 ACCEPTED SOLUTION

Accepted Solutions
justinburch
Microsoft
Microsoft

Hi @shahriat,

Just remove the undefined check, there does seem to be a current issue where the code to establish that function is not being included in Web Forms. Another community user ran into the same.

f (window.jQuery) { (function ($) { if (typeof (webFormClientValidate) != 'undefined') { var originalValidationFunction = webFormClientValidate; if (originalValidationFunction && typeof (originalValidationFunction) == "function") { webFormClientValidate = 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)); }

$(document).ready(function () {
  webFormClientValidate = function () {
    $.ajax(....);
  };
});

View solution in original post

2 REPLIES 2
justinburch
Microsoft
Microsoft

Hi @shahriat,

Just remove the undefined check, there does seem to be a current issue where the code to establish that function is not being included in Web Forms. Another community user ran into the same.

f (window.jQuery) { (function ($) { if (typeof (webFormClientValidate) != 'undefined') { var originalValidationFunction = webFormClientValidate; if (originalValidationFunction && typeof (originalValidationFunction) == "function") { webFormClientValidate = 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)); }

$(document).ready(function () {
  webFormClientValidate = function () {
    $.ajax(....);
  };
});

View solution in original post

Hi Justin,

Thanks a lot for your valuable response.

I need another help, like in the step2 I have a map where I draw shapes. Before going to final step I want to pass a json with those shapes to final step. 

 

Could you please help how can I pass json data to the 3rd step?

 

-

Thanks

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Users online (68,725)