Hi,
When we created a Pre/Post image, we typically select all attributes to be included. There's a performance hit.
I compiled a list of which attributes should be passed in for the particular image under the plugin step (create sync, create async, update, delete, etc,.)
Some of the images need to include 25+ attributes. I do not want to go through and check those attributes one by one. Please suggest a way to accomplish this task via CRM SDK if I defined attribute schema names.
Our setup:
XrmToolBox tools to help with CRM Plugin development:
Please let me know if you use any other XrmToolBox tools or otherwise to help with plugin registration/step creation/image creation/image attribute selection.
Thank you for taking your time to answer this. Let me know if I can elaborate further on my request. Please answer the 2 questions in bold so that I can select your answer as the best one.
*This post is locked for comments
[quote user=""Francesco"][/quote]
In every plugin where i need to deal to pre-post images i simply call a query to retrieve the full or partial entity,
I don't think you are grasping the power of Images. Most the time I will write a plugin over a custom workflow activity so that I can see what the record was before the change. Let say I have 5 statuses for a single state and I need to treat the situation of transitioning from status 2 to 3 different from the transition from 1 to 2. I can get the pre-image and compare it next to the post-image (or the target) to see how to handle it. There are also ways to cause an Update plugin to fire without the field really changing. Sometimes you might need to check to make sure it really changed and even though the Target shows the field as having changed you won't know without the pre-image.
As far as I have seen the difference between grabbing a whole image vs a partial image is very small and most the time not even noticeable. I tested this with an entity that had >300 fields, using the plugin trace log, I couldn't see a difference between grabbing 5 fields vs all attributes.
To answer your question which has already been answered I have not seen a tool that can take a list of field names and add the attributes to the registered image but the XrmToolkit might have something.
Basically the combination of both answers above would give you the results that you are looking for:
The following will give you the results of the Post-Execution
Entity changed = context.InputParameters["Target"]
or
Entity allAttributes = service.Retrieve(entityName, entityId, new ColumnSet(true));
To get the Pre-Execution, you can either use Pre-Image or you can create a plugin step that runs in Pre-Execution and gets the list of all changed fields which can be passed to post-execution.
This is done by using the context.SharedVariables functions.
You have a few different options here to get the input parameters and check/compare them in the Post Execution step.
The logic to use is up to you. Always there are different options for the same task.
Hi Anatoly,
The Target entity accessible in Input Parameters contains in its attributes collection only the attributes which are being changed.
Francesco, thanks for the reply!
I have no problem with using a SDK retrieve for post image, but if I want to get the pre-image for value comparisons, I won't be able to with retrieve.
How do you know if the owner of the record changed. What about a dollar value? (If the logic requires these kind of comparisons.
Thanks!
Hi Anatoliy,
like you, i dont link Pre and Post Image.
In every plugin where i need to deal to pre-post images i simply call a query to retrieve the full or partial entity, like:
Entity fullentity = service.Retrieve(entityFromTarget.LogicalName, entityFromTarget.Id, new ColumnSet(true /*or fields i need*/));
It may seems a "performance miner", however is:
- clear
- flexible
- fast to implement and modify
- fast to search (no-headache when you deal with missing fields ...)
Hope it helps!
If you found the answer helpful, please mark as Verified
Join my network on LinkedIn Follow me on Twitter
Thank You & Best Regards
Francesco Picchi
Microsoft Dynamics CRM Consultant, Bologna+Milano, ITALY
Independent Contractor
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156