setSubmitMode on Lookup not doing anything RRS feed

  • Question

  • Hi

    I have a plugin. It requires information from the current service activity for its function. Related to the service activity is a custom entity. On the form it is used as a lookup. If i change the value and save the record, everything works fine. If i dont change the value in the lookup and save the record, it errors out. I have debugged it, and can see that the lookup value is not being passed to the plugin, because it hasnt changed. I have then implemented jscript in an attempt to setSubmitMode("always"). The jscript runs (alerts eithe side of the setsubmitmode call are seen). So my guess is that because the value hasnt changed, its still nopt submitted back to the plugin. How can i force the lookup value to be resubmitted to the plugin ?



    Thursday, November 17, 2011 7:23 AM

All replies

  • Hi Luke,

    Did you ever find an answer. I have the exact same problem on the Service Activity entity on the regardingobjectid field. Even though setSubmitMode = always, when the plugin executes, the RegardingObjectId is null.

    Any explanation?


    Thursday, January 5, 2012 2:36 AM
  • Hi Luke,


    Use PreImage with your plugin, means even if the user didn't change the value, you can look at the preimage entity and do the logic. Please refer CRM SDK and it has examples.

    This way you don't have to use javascript.

    please see the following to get some idea about pre-image, following are from my response to another forum thread.



    Just some thoughts with example.

    Pre-Image is a snapshot of record before the platform update and Post-Image is a snapshot of after the update.

    You will use Pre-Image when you you have a Plugin registered on Update message & Pre-Validation or Pre-Operation stage. On that Plugin you can check what was the Previous value from Pre-Image and current value from Target, you can overwrite users input (entered value) from Pre-Image and Update the Target attribute and the platform will update the entity record with the value you have changed.

    Post Image you will use, if you have Plugin on Update message & Post-Operation, and on that Plugin you can write logic which reads data from Post-Image and then update an external system for example.

    From Erez Yaron:

    They can be used to make sure you have data from the entity in your plugin code without the need to go get it thru a separate call.

    the Target entity will have fields that have been set. if you have an update plugin the target will only contain attributes that have actually been updated, so if a user opens a contact record and changes the first name and hits save, the target entity will have the contact id and the first name fields. if your plugin needs to have logic based on other fields you can use the images (either pre or post) to make sure those fields are always there as well. this is faster and more efficient than making an outside call back to CRM to retrieve data



    Thomas T(MCBMSS) If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".
    Thursday, January 5, 2012 6:06 AM
  • As I understand, you need the value of a lookup (regarding) in your plugin. But since the regarding is not changed, you do not get this value in the plugin.

    If my understanding is correct, you can implement Images in the Plugin. Register your plugin to include Images and select the attributes that you want the plugin to receive irrespective of whether these were edited or not.

    You can read further details from the SDK.



    Dynamics CRM MVP | Inogic | http://inogic.blogspot.com| news at inogic dot com

    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

    • Proposed as answer by Sam - Inogic Thursday, January 5, 2012 8:54 AM
    Thursday, January 5, 2012 8:53 AM