Hi,
I am working with Dynamics 365 instance. If I am not wrong 'SetStateRequest' will be deprecated and 'UpdateRequest' should be used instead. I am trying to reactivate a Paid (Completed) invoice.
But with following 'UpdateRequest' it throws an error "The entity cannot be updated because it is read-only".
var invoiceToUpdate = new Entity("invoice", new Guid("D9588C16-EA18-E611-80E4-000D3A2362ED"));
invoiceToUpdate["statecode"] = new OptionSetValue(0);
invoiceToUpdate["statuscode"] = new OptionSetValue(1);
UpdateRequest request = new UpdateRequest()
{
Target = invoiceToUpdate
};
orgService.Execute(request);
But it works if I try 'SetStateRequest' as below:
SetStateRequest setStateRequest = new SetStateRequest()
{
EntityMoniker = new EntityReference
{
Id = new Guid("D9588C16-EA18-E611-80E4-000D3A2362ED"),
LogicalName = "invoice",
},
State = new OptionSetValue(0),
Status = new OptionSetValue(1)
};
orgService.Execute(setStateRequest);
Can anyone please explain why it works with a deprecated message but not with Suggested Method.
Thanks
*This post is locked for comments
I have the same question (0)