locked
Can Reflection be used to modify the IsValidForUpdate flag? RRS feed

  • Question

  • Is it possible to use Reflection to get at the IsValidForUpdateFlag for a field on an entity record?

    I am trying to set to null the Cancel date for a Contract when the date is set in the future and the user decides not to cancel that Contract after all. I have asked this question in other ways in this forum but received no answer, so I thought I'd try one more time, in a different way.

    Thanks for all information and suggestions!

    Monday, February 10, 2014 4:39 PM

All replies

  • You aren't able to modify the value for IsValidForUpdate - it is part of the system metadata related to the individual fields. This is basically saying the the system level that the given field can be updated. An example where this would be false would be CreatedOn - this field can only be set during the record's creation but the value cannot be changed via an update. 

    Maybe I am misunderstanding what you are looking to use this value for, but otherwise you can get at the metadata value like this:

    RetrieveAttributeRequest req = new RetrieveAttributeRequest
    {
    	EntityLogicalName = "account",
    	LogicalName = "name"
    };
    
    RetrieveAttributeResponse resp = (RetrieveAttributeResponse)_serviceProxy.Execute(req);
    bool? isValidForUpdate = resp.AttributeMetadata.IsValidForUpdate;


    Jason Lattimer
    My Blog -  Follow me on Twitter -  LinkedIn

    Monday, February 10, 2014 5:01 PM
    Moderator
  • Thanks for responding, Jason.

    CRM has a CancelContractRequest message which I am using to set the Cancel Date. Can you think of anyway to "cancel the cancel" if the cancel date is in the future? 

    I suppose I can re-cancel the Contract, since the State is still Active, and this time set the Cancel Date to Today, then reinstate the Contract and set the expires on date to the original one, but I was  hoping for a simpler method.

    Monday, February 10, 2014 6:00 PM
  • Can you register a plugin on the Cancel message of the Contract and then check the date and throw an exception if the date is not valid?

    Jason Lattimer
    My Blog -  Follow me on Twitter -  LinkedIn

    Monday, February 10, 2014 7:08 PM
    Moderator
  • Future dates are valid (both in CRM and by our business rules), but they can change their minds.
    Monday, February 10, 2014 8:52 PM