locked
Updation of createdon and modifiedon fields through plugin RRS feed

  • Question

  • Hi Folks,

    I need to update the  createdon and modifiedon fields of the record when it is created/ updated. The records are created/updated manually. After the records are created/ modified, I need to update the fields (through plugin)

    How do I achieve this? 

    I tried pre and post plugin messages on create event.

    In post create I need to update the fields (createdon and modifiedon) which is not supported.

    I also tried using  the pre - create plugin:

    Entity Entity1= (Entity)context.InputParameters["Target"];

    Entity1["overriddencreatedon"] = usersLocalTime;


    1. createdon is not updatable through supported means i.e. SDK and webservices

    2. To update createdon, we need to update at SQL level, this is unsupported.

    I referred to the following links: 

    http://mostlymscrm.blogspot.in/2012/07/understanding-createdon-and.html

    Kind Regards,

    Rameshwari


    Friday, October 11, 2013 8:19 AM

All replies

  • Hello,

    You can't modify createdon date once record is created using supported methods, so it won't work in plugin, but you can change overriddencreatedon.


    Our Website | Our Blog | Follow US | My Facebook Page | Microsoft Dynamics CRM 2011 Application Design
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    Friday, October 11, 2013 8:40 AM
    Moderator
  • Hi Mahender Sir,

    The reason I am setting the value of overriddencreatedon is that overriddencreatedon will be swapped with createdon upon record creation. According to the link http://mostlymscrm.blogspot.in/2012/07/understanding-createdon-and.html, I understand that the fields "overriddencreatedon " and "createdon " will be swapped upon record creation in the plugin. 

    I have a concern that I am creating/updating the record manually and I need to update the values of createdon and modifiedon of the record through plugin.

    Please correct me if I am wrong.

    Kind Regards,

    Rameshwari

    Friday, October 11, 2013 10:03 AM
  • Hi,

    The problem is I am creating the record manually. And then firing the plugin .

    So the entity is taken from context.

    I need to update the createdon of the above created entity. 

    Service.update() did n't work. I have already tried it.

     :(

    Kind Regards,

    Rameshwari

    Friday, October 11, 2013 10:06 AM
  • Hi,

    You can't update creadedon field directly. You will have to update overriddencreatedon  using service.update(). It will swap the values.

    It will work.

    HTH!

    Thanks!

    Saturday, October 12, 2013 5:46 AM