Skip to content
This repository has been archived by the owner on Jun 16, 2024. It is now read-only.

ExecutePluginWith<T>(...) has no parameter for MessageName - need to use obselete method ExecutePluginWithTargetAndPreEntityImages<T>(...) #597

Closed
thomas-schiller opened this issue Aug 17, 2022 · 2 comments
Labels

Comments

@thomas-schiller
Copy link

My PostUpdate plugin uses a preImage.
I need to set the PreImage for my plugin execution. I don't see any possiblity to pass an PreImage AND set the message name to "Update" (always default--> "Create")

Hence I am forced to use the obsolete method "ExecutePluginWithTargetAndPreEntityImages". The obsolete warning tells me to use "ExecutePluginWith", but I don't find any possiblity to set the message name.
Am I wrong?

@jordimontana82
Copy link
Owner

Hi Thomas,

It is indeed possible. You can use the GetDefaultPluginContext method to retrieve a default context and override whatever is needed before passing it into the ExecutePluginWith method, including setting any PreEntityImages you want as well as the message name:

MessageName = "Create",
UserId = userId,
BusinessUnitId = businessUnitId,
InitiatingUserId = userId,
InputParameters = new ParameterCollection(),
OutputParameters = new ParameterCollection(),
SharedVariables = new ParameterCollection(),
PreEntityImages = new EntityImageCollection(),
PostEntityImages = new EntityImageCollection(),
IsolationMode = 1

Also, you might want to take a look at the later version cause v1.x is deprecated and will stop receiving updates soon....

https://dynamicsvalue.github.io/fake-xrm-easy-docs/quickstart/migrating-from-1x/

Feel free to ping me if you still have questions.

@jordimontana82
Copy link
Owner

I'm also adding a sample using that approach, not necessarily for PreEntityImages but other InputParameters, although it should work as well:

https://dynamicsvalue.github.io/fake-xrm-easy-docs/quickstart/plugins/overview/

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants