Shafqat Ali
Shafqat Ali

Reputation: 11

How do I create a plug-in to update the 'Modified By' column with the 'Owner' value in d365 entity?

Can I change the Modified by column in d365 entity

Hello everyone as I was trying to change the modified by column with a value of column owner in my model driven i want as I create any record it should change the value of column modified by as in owner. I want to achieve this plug in. Note: Is it possible to change the value in modified by column.

Upvotes: 0

Views: 472

Answers (2)

Daryl
Daryl

Reputation: 18895

First off, I question why this is a requirement for the modified by to be the owner. But here are some options in the order in which I would recommend:

  1. If you're creating the record programmatically, then using impersonation to create the record, impersonating the owner. The system will then set the created by and modified by to be the owner.
  2. You can attempt to update the modified by in the target of a pre update operation plugin, I don't know if that works though...
  3. Create a post create sync plugin that creates an IOrganizationService that impersonates the owner, and have it update the same value like the owner with the value it already is.
  4. Create a retrieve and retrievemultiple plugin post operation plugin that inject the owner id into the modified by. Note - This means filters in queries will not match the results since the data in the DB isn't what is being injected, and you'll need a matching pre operation plugin to ensure the owner id is added to the query.

Upvotes: 0

jasonscript
jasonscript

Reputation: 6180

ModifiedOn is a system-field which is automatically updated with the id of whichever user account modified the record.

If you're creating records, and assigning them to another user, the modifiedon field will still be the user that created the record, not the user that owned the record

Upvotes: 0

Related Questions