Dea All,
I want to add a custom logic while creating fields in an entity in Dynamics 365.
The requirement is : when creating new field in an entity A => create clone of the field in entity B.
To do so, i can use the message : CreateAttributeRequest.
Now i need to catch the event of creation of a field.
In Plugin Registration Tool, i found the message: CreateAttibute, so i tried to register a step in my plugin but still i cannot fill a valid Primary Entity Name. I get the error below :
So i tried to leave it clear and still i got an error while registring the step.
Can someone suggest me something please ?
Hi Saad,
Yes, it is possible to create Attributes/Fields using a plugin, but you need to adjust the Message and Event Pipeline Stage of Execution of your Plugin, taking in consideration the information below:
Unfortunately it is not possible to use this message CreateAttribute as a trigger for the plugin. There are many Messages that, although you can see into the PRT (Plugin Registration Tool) drop list, it is not really available. PRT runs a query against a table in CRM that list all the messages but it doesn’t mean that all of them are available to register.
There is an easy way that you can confirm if a message is functional, which is trying to type only the first word of the Entity, PRT must auto complete the Entity name if such Entity is a valid PrimaryEntity for that message (see print screen below as example). If PRT is not auto completing the name of the Entity, it means that such Entity is not valid for the given message. If there is no PrimaryEntity valid for a given message it means that the message is actually not available for register a plugin. That is the case for message CreateAttribute.
If you want to confirm all the valid Messages to be registered in a Plugin, you can follow this documentation: https://powerapps.microsoft.com/en-us/blog/find-messages-and-entities-eligible-for-plug-ins-using-the-common-data-service/ or just run this web api below in your browser, and you will check that CreateAttribute will not be listed there:
https://<YourOrg>/api/data/v9.1/sdkmessages?$select=name&$filter=isprivate eq false and (name ne 'SetStateDynamicEntity' and name ne 'RemoveRelated' and name ne 'SetRelated' and name ne 'Execute') and sdkmessageid_sdkmessagefilter/any(s:s/iscustomprocessingstepallowed eq true and s/isvisible eq true)&$expand=sdkmessageid_sdkmessagefilter($select=primaryobjecttypecode;$filter=iscustomprocessingstepallowed eq true and isvisible eq true)&$orderby=name
More information available here: https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/event-framework
Said that, you must use a different Message to trigger your plugin.
Create an Attribute from a Plugin is possible, but you must take in consideration some specifics:
For Pre-Operation and Post Operation this behavior won't be possible. You would get an Exception like this: "You cannot start a transaction with a different isolation level than is already set on the current transaction".
Therefore you must register the plugin in Pre-Validation or Async Post-Operation, for the last one, the attribute will not be available until you run Entity Publish or Publish all
Sample code and more details are available in this thread: https://community.dynamics.com/365/sales/f/dynamics-365-for-sales-forum/382428/createattributerequest---field-is-created-but-cannot-be-found
Hi Saad,
This is not possible. You can not automatically create fields in an entity. You have to use the "Customize the system" to create a field in an entity.
No its not regarding the data, its regarding the definition of the field.
I want to automate the creation of fields in entities :
=> From the solution, if i create a field in entity A, i want to create automatically an image of the field in the entity B.
For this i need to know which message to use and what primary entity to use. is there any supported way designed by Microsoft ?
Hi,
I am a little confuse on what you are asking. Are you saying that you want to take data from Entity A and copy that data to Entity B.
If this is what you are trying to do, then use the plugin postoperation on Entity A and Update Entity B from Entity A.
I am accusing your question.
Hi Saad,
Accordingly with docs.microsoft.com/.../supported-messages-entities-plugin
there is no such message with name "CreateAttribute" for plugins for custom entities. Same for account
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,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156