locked
CRM 2013: Plug-In Order of Events Assign Vs Update RRS feed

  • Question

  • I've hit a small problem regarding the execution order of events within CRM 2013.

    This problem only effects the "Update" Plug-In event and not "Create".
    Also I must process this Synchronously due business logic feed-back to the UI, so Asynch is out.

    I'm trying to create an activity record off the back of the Account Entity when a date is entered into one of the fields.
    I have a filtered Update Plug-In watching for the field change. When the date is entered the record is created and everything is fine.

    However, in some circumstances the Account record is being assigned to a new owner at the same time the date is entered.

    When the Plug-In fires the Target entity within the context does not contain the OwnerId, so its forced to get this from the database, which of course is the old owner and not the new one.

    Because this change is firing two events (Assign and Update) I really need the assign to take place first before the update does. Because of what I'm doing on the activity record I cannot wait for cascade updates to rescue me.

    I know you can change the order of Plug-In events firing based upon a numeric value, but can I ensure the Assign message is processed before the Update, or find some way to get the OwnerId value into the Target Context where I can see it?

    Any help greatfully received

    Steve


    • Edited by lemonje Tuesday, October 13, 2015 5:03 PM grammer
    Tuesday, October 13, 2015 5:00 PM

All replies

  • I have the same problem 

    Did you find any solution?

    Tuesday, January 5, 2016 7:49 AM
  • Can you describe the circumstances where 'in some circumstances the Account record is being assigned to a new owner at the same time the date is entered' ? Is it that the user is changing the owner lookup as well as the date field, and then performing a Save, or is the user do 2 separate operations - i.e. saving a change the date field, and assigning a new owner ? And is AutoSave involved ?

    If the user instigates 2 separate operations, then I think there is nothing you can do to link the 2. If it's one operation, then you can't change the order of operations, but you may be able to use SharedVariables to pass data between a plugin registered on the Assign, and one on the Update. You could also try the different pre-event stages (pre-validation and pre-operation), as these stages may work differently from each other.

    Finally, could you write a plugin on the Assign, and in that plugin make changes to the record created in the Update plugin, to reflect the new owner ?


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

    Tuesday, January 5, 2016 9:43 AM
    Moderator