Requirement:
To identify if a record CRUD operation was done from Dynamics UI or from Web API at plugin .
Solution that worked until now:
By Checking the value of “context.ParentContext.ParentContext” in the plugin we were able to distinguish the source of request (Dynamics UI/ API)
if value of “context.ParentContext.ParentContext” is null, it meant record was created from UI
If value of “context.ParentContext.ParentContext” is NOT null, we assumed that record was created using API
|
Value |
Source |
context.ParentContext.ParentContext |
Null |
Dynamics UI |
Not Null |
Web API |
But we have now run into another issue after introducing “Business Process Flow” for an entity. Below is the details around the issue.
Current Issue:
When a Business process flow is added to an entity. For e.g. Let’s call it “myEntity”. Dynamics creates another inbuilt entity called “myEntity Process” entity which stores the stages. When a user creates a “myEntity” record , two create requests are fired on plugin, as below:
- “myEntity” entity's create event
- “myEntity Process” entity's create event
After the business process flow was added below is the behavior for both the entities.
For create event on “myEntity”, we have different behaviours on different version of dynamics:
- On 8.2 on-premises – The context.ParentContext.ParentContext object is NULL as expected when a record is created from Dynamics UI.
- On 9.0 online - the context.ParentContext.ParentContext object is not NULL when a record is created from Dynamics UI
For create event on “MyEntity Process” create event the "context.ParentContext.ParentContext" is not NULL for on prem and online instances as well.
Based on this behavior, we have the below questions.
Questions:
- What is a fool proof solution to identify CRUD operations done through web API vs CRUD operations done through Form to prevent the plug-in from executing repeatedly.
- Why is there a different in behavior between 8.2 and 9.0 myEntity explained above?
*This post is locked for comments