Answered by:
CRM 2011 Origin of Create event

Question
-
Hello
In my plugin, i have a "Create" event, linked to an entity. This event is fired by :
- the entity's associated form, when the user click on the "Save" button
- after the calling of the "localContext.OrganizationService.Create(my entity)" method
I would know which element has fired this "Create" event. From the form, or from the Create method ?
Except creating a flag in the entity, which will be initialized according the calling context, is there a more elegant method ?
Thanks !- Edited by Osmont Emmanuel Saturday, July 13, 2013 5:59 AM
Saturday, July 13, 2013 5:58 AM
Answers
-
Hi,
Maybe you could use the Depth property of the executing context to determine if it was called from another plugin.
That could give you an origin in several cases.
You'll find a good overview about your possibilities at: http://blog.simpletrees.com/2012/03/executioncontextcallerorigin-in.html
Best regards
Steve Sämmang, Vienna, Austria
Blog: xrm.io Website: simplic.at- Edited by saemmang Saturday, July 13, 2013 7:21 AM typo
- Marked as answer by Osmont Emmanuel Monday, July 15, 2013 9:00 AM
Saturday, July 13, 2013 7:20 AM
All replies
-
Hi,
sadly there isn't a more elegant method.
CRM 4.0 had the Origin property to differentiate the origin of the call http://msdn.microsoft.com/en-us/library/cc156328.aspxYou need to use a field flag as you already doing.
My blog: www.crmanswers.net
- Proposed as answer by Guido PreiteMVP Saturday, July 13, 2013 6:45 AM
Saturday, July 13, 2013 6:45 AM -
Hi,
Maybe you could use the Depth property of the executing context to determine if it was called from another plugin.
That could give you an origin in several cases.
You'll find a good overview about your possibilities at: http://blog.simpletrees.com/2012/03/executioncontextcallerorigin-in.html
Best regards
Steve Sämmang, Vienna, Austria
Blog: xrm.io Website: simplic.at- Edited by saemmang Saturday, July 13, 2013 7:21 AM typo
- Marked as answer by Osmont Emmanuel Monday, July 15, 2013 9:00 AM
Saturday, July 13, 2013 7:20 AM -
Did you check this :http://a33ik.blogspot.in/2012/06/callerorigin-in-plugins.html
Our Website | Our Blog | Follow US | My Facebook Page | Microsoft Dynamics CRM 2011 Application Design
Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.Sunday, July 14, 2013 4:21 PMModerator -
I would go for the depth check. If the plugin is triggered by a user creating a record through the UI the depth will be 1, if it's triggered by another plugin the depth will always be >1.
Paul
If my response helped you find your answer please show your thanks by taking the time to "Mark As Answer" and "Vote As Helpful".
Monday, July 15, 2013 8:29 AM -
Hi
Thanks Steve, the Depth give me the best way to distingish the calling context.
Best regards,
Emmanuel
Monday, July 15, 2013 9:02 AM -
Did you check this :http://a33ik.blogspot.in/2012/06/callerorigin-in-plugins.html
Our Website | Our Blog | Follow US | My Facebook Page | Microsoft Dynamics CRM 2011 Application Design
Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.Thanks for your response, but the Origin property always returns "Application".
- Edited by Osmont Emmanuel Monday, July 15, 2013 9:04 AM grammar
Monday, July 15, 2013 9:04 AM