c# - How to cancel create an cativity action on ms crm 4.0? -



c# - How to cancel create an cativity action on ms crm 4.0? -

i have plugin activity.

on pre create check few conditions , if true throw operationcanceledexception stop create execution.

but record saved, why? how can cancel creation? tried throw invalidpluginexecutionexception, it's stil executed..

the code:

public void execute(ipluginexecutioncontext context) { seek { switch (context.messagename) { case "create": if (context.stage == messageprocessingstage.beforemainoperationoutsidetransaction) { bool shouldnotcreateactivity = create(context, service); if (shouldnotcreateactivity) throw new operationcanceledexception(); } if (context.outputparameters.properties.contains("id")) { //continue... } break; } } grab (operationcanceledexception cancled) { } grab (invalidpluginexecutionexception invalid) { } grab (soapexception ex) { } grab (exception ex) { } }

sounds doing wrong. should post of code realting pre-checking , saving of activity

you should have logic following...

if(validateactivity()){ createandsaveactivity(); } else throw execption;

c# dynamics-crm-4

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -