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 / Trying to alter Submit...
Power Pages
Answered

Trying to alter Submit function through try and catch block

(0) ShareShare
ReportReport
Posted on by 264

Hi Community,

I am trying to alter the submit function on muti step form and perform custom code through try and catch block.
But even if the code is comes in catch block , the submit function executes.

My code:

$('#Button').click(function (e)
{

e.preventDefault();
try
{
if ($('#hello').val = "true")
{
$('#Button').esubmit();
//Intention error esubmit

// if I use .click function, it goes in a loop, hence tried prevent.default
}
else
{
$('#hello').val("");

//assigning it to null
}
}
catch (exceptionVar)
{
alert("Hello");
}
finally
{
alert("Hello");
}

});

 

//my code catch the error, alerts hello, but still submits. and got o finally block.
I do not want it to submit. once catch in catch block 

 

any help is apperciated.

Categories:
I have the same question (0)
  • Verified answer
    Fubar Profile Picture
    8,487 Super User 2026 Season 1 on at

    You cannot just add your own on click.  There may be workarounds to it (e.g. hide the standard button, add your own button, then click the hidden button) but need to know why do you need to do it?

     

  • Paul_M Profile Picture
    264 on at

    Hi @Fubar ,

    Thank you for the reply.
    The work around is really good, thank you.
    I want to alter the submit button, put it in a try and catch block.

    To show any error message, if the connection between portal and 365 fail.
    I tried using prevent default or the normal try and catch.
    Prevent Default does not work and
    Even if it comes to catch, it performs the submit button functionality.

     

  • Paul_M Profile Picture
    264 on at

    Hi @Fubar ,

    I cannot believe the workaround was so simple.
    Thank you for your help, the solution worked.

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!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Pages

#1
rezarizvii Profile Picture

rezarizvii 64

#2
DP_Prabh Profile Picture

DP_Prabh 34

#3
oliver.rodrigues Profile Picture

oliver.rodrigues 30 Most Valuable Professional

Last 30 days Overall leaderboard