Asked by:
Clearing the Cancel On date on a Contract

General discussion
-
CRM allows a future date for the Cancel On date for a Contract. If between today and the Cancel On date, we choose to suspend cancellation of the Contract, we need a way of removing or clearing that date.
If I try to say:
contract.CancelOn = null;
I get a an error: "Property of Indexer 'Xrm.Contract.CancelOn' cannot be assigned to - it is read only"
I can't use the SetStateRequest message because the contract is still Active.
Has anyone accomplished this? Any ideas? Thank you....
Thursday, January 16, 2014 9:35 PM
All replies
-
I think you have to change firstly metadata of CancelOnfield
IsValidForUpdate:false->true
after that we will update this field.
see EntityMetadata excel sheet in SDK for details.
Hope this helps. ----------------------------------------------------------------------- Santosh Bhagat If this post answers your question, please click "Mark As Answer" on the post and "Vote as Helpful"
Friday, January 17, 2014 3:55 AM -
Thanks for responding, Santosh!
I found the spreadsheet and I found the entry for CancelOn. However, I haven't been able to find anything on editing the EntityMetaData. Can you be more explicit?
Thank you again.
Update:
I found some instruction at http://msdn.microsoft.com/en-us/library/microsoft.xrm.sdk.messages.updateentityrequest.aspx and I will give it a go.I am basing my code on the example at:
http://msdn.microsoft.com/en-us/library/gg509014(v=crm.6).aspx
I need to edit the metadata for a field on the Contract entity. I can get to the Contract entity's own metadata, but not that of its fields. Has anyone done this?
My code so far:
RetrieveEntityRequest retrieveContractEntityRequest = new RetrieveEntityRequest { EntityFilters = EntityFilters.Entity, LogicalName = Xrm.Contract.EntityLogicalName }; RetrieveEntityResponse retrieveContractEntityResponse = (RetrieveEntityResponse)_service.Execute(retrieveContractEntityRequest); EntityMetadata ContractEntity = retrieveContractEntityResponse.EntityMetadata; ContractEntity.Attributes[iInt].IsValidForUpdate = true;
but ContractEntity.Attributes[] takes an integer and I don't know what to populate here. Can anyone guide me? Thanks!
- Edited by MeProgrammer Friday, January 17, 2014 3:42 PM typo
Friday, January 17, 2014 2:37 PM -
Further update:
isValidForUpdate is read-only.
Does anyoen know how I can accomplish a cancellation of suspension of a future Cancel date on a Contract? One possibility is to re execute CancelContractRequest with today's date, and then Renew it. When renewed, it will be in draft mode so it can be updated, and I can change the dates to match the original, and then shange its State so it is Active.... but perhaps there is a more elegant solution?
Friday, January 17, 2014 6:33 PM