locked
Using a plugin to create a Workflow Record RRS feed

  • Question

  • I have registered a plugin against the creation of records in an entity. The record creation is done via a Workflow.

    The plugin registers fine against the entity. When I try to create a record using the Workflow the record is created fine but I am trying to write to a field in the record and it wont add to it. I am using the following line of code but hs5 doesn't get updated.

    var newNumber = "20/10/2015";

    entity.Attributes.Add("hs5", newNumber);

    Tuesday, October 20, 2015 2:37 PM

All replies

  • Hello,

    I'm pretty sure that you use wrong field name. I believe it should be custom field something like "new_hs5"


    Dynamics CRM MVP
    My blog

    Tuesday, October 20, 2015 3:46 PM
    Moderator
  • It seems that I have done something wrong when I started my plugin.

    • Edited by JMcCon Wednesday, October 21, 2015 8:39 AM
    Wednesday, October 21, 2015 8:20 AM
  • The Entity that I am registering the plugin against is an Activity Entity.

    Can plugins run against activity entities?

    Wednesday, October 21, 2015 10:28 AM
  • Hi,

    You can runt plugins against activity entity, which activity is it you're using? What sort of field is the one you're trying to update and what is the schema name of the field?

    How are you executing the plugin (how is it registered)?

    Regards


    Rickard Norström Developer CRM-Konsulterna
    http://www.crmkonsulterna.se
    Swedish Dynamics CRM Forum: http://www.crmforum.se
    My Blog: http://rickardnorstrom.blogspot.se

    Wednesday, October 21, 2015 10:35 AM
  • Rickard I created the Entity myself as an Activity Entity. The field is a text box. Schema name is new_hs5. I am registering using the CRM Plug-in registration tool in Visual studio 2010. I have even taken code from a plugin that is executing fine and it wont work in this plugin. The only difference between this one and the one that works is that there is no workflow and the entity isnt an activity.
    Wednesday, October 21, 2015 11:49 AM
  • Can you clarify if the plugin works as expected if you create a record of this type in CRM, not via a workflow ?

    Also, what stage is the plugin registered on ? For activity entities there are differences in behaviour between the pre-operation and pre-validation stages, for example


    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    Wednesday, October 21, 2015 12:50 PM
    Moderator
  • Hi,

    As Andrii wrote, change the field name to "new_hs5", then make sure that you have it registered in pre-operation state so that the attribute bag gets pushed to CRM.

    You could also try to debug the plugin to see what actually happens, if the code is running you should get a "key not found exception" with the current code so my guess is that it isn't executing.

    Regards


    Rickard Norström Developer CRM-Konsulterna
    http://www.crmkonsulterna.se
    Swedish Dynamics CRM Forum: http://www.crmforum.se
    My Blog: http://rickardnorstrom.blogspot.se


    Wednesday, October 21, 2015 12:51 PM
  • Rickard I dont understand why it is not executing because the same code is used in another plugin which works fine and is the exact same.
    Wednesday, October 21, 2015 2:44 PM
  • how is it registered, on create or update? Pre or post operation?

    Regards


    Rickard Norström Developer CRM-Konsulterna
    http://www.crmkonsulterna.se
    Swedish Dynamics CRM Forum: http://www.crmforum.se
    My Blog: http://rickardnorstrom.blogspot.se

    Wednesday, October 21, 2015 2:46 PM