How to check ExecutionObj.getEventArgs().isDefaultPrevented() from ribbon button in dynamics crm 2011
-
Friday, May 25, 2012 3:36 AMXrm.Page.data.entity.save(); // some mandatory fields validated here
var result =ExecutionObj.getEventArgs().isDefaultPrevented()
How to check ExecutionObj.getEventArgs().isDefaultPrevented() from ribbon button in dynamics crm 2011.
Suresh kumar
All Replies
-
Friday, May 25, 2012 4:06 AM
Suresh,
Can you advice what you are trying to do with this from the Ribbon button?
Do you want to check to see if the Save / Update action cancelled from the ribbon button?
Dimaz Pramudya - CRM Developer - CSG (Melbourne) www.xrmbits.com http://twitter.com/xrmbits
-
Friday, May 25, 2012 7:39 AM
I have written custom code on case form ribbon button to replace the actual Resolve Case button to bypass caseresolution window.
On the click of the button I am saving the form values and then I am creating a caseresolution activity for closing the case.
The code is like that
Xrm.Page.data.entity.save();
CreateCaseResolution();
But if mendatory fields are not filled in the case form then CreateCaseResolution() should not be executed.
Suresh kumar
-
Friday, May 25, 2012 9:32 AMModerator
Hi,
you can try
if(!ExecutionObj.getEventArgs().isDefaultPrevented())
{
CreateCaseResolution();
}
Mahain : Check My Blog
Follow me on Twitter
Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question. -
Friday, May 25, 2012 9:53 AMBut ExecutionObj is not available on code executed from ribbon button
Suresh kumar
-
Friday, May 25, 2012 9:59 AMModerator
But ExecutionObj is not available on code executed from ribbon button
Suresh kumar
You can always use following code:
if (Xrm.Page.context.getEventArgs().isDefaultPrevented()) { //your logic here }
Microsoft CRM Freelancer
My blog (english)
Мой блог (русскоязычный)
-
Saturday, May 26, 2012 3:13 AM
Dear Andrii Butenko,
if (Xrm.Page.context.getEventArgs().isDefaultPrevented()) { //your logic here }
This code is not working.
Error is like below
context object doesn't support property or method
.getEventArgs()
Suresh kumar
-
Saturday, May 26, 2012 6:07 AMModerator
In case you will put this code to the proper place (I mean OnSave handler) - it will work. I have done it many times and it works without any miserable issue.
In your specific case you should not try to catch those value somehow. My opinion that you should change architecture of your solution.
To help you help us - please post here design of form and describe full scenario you want to reach.
Microsoft CRM Freelancer
My blog (english)
Мой блог (русскоязычный)
-
Tuesday, April 16, 2013 6:51 AM
Hi,
Hopefully I did not re-open the question.
Today I got some similar problem with the questioner, I resolved it by:
1. make a function that accept 1 parameter as execution context
2. on form properties, where I registered the script, tick "Pass execution context as first parameter"
Below is the sample script that I made:
function SaveValidation(executionContext){ if(executionContext.getEventArgs().isDefaultPrevented()){ // logic here } }

