Hello, I became aware of something in Dynamics programming through C#. It is about setting the state as well as status code through the script.
Although all permissions are given for both read and write, I get the exception/error : "This entity is readonly." The setting of the state and status code is done as follows:
entity["statecode"] = new OptionSetValue(0); entity["statuscode"] = new OptionSetValue(1); service.Update(entity);
The interesting thing is that this way works in many other examples... but not for the "invoice" entity. So what is being done? I tried this with the SetStateRequest class - which also eventually led to success.
SetStateRequest setStateRequest = new SetStateRequest() { EntityMoniker = new EntityReference { Id = invoice.Id, LogicalName = "invoice", }, State = new OptionSetValue(0), Status = new OptionSetValue(1) }; service.Execute(setStateRequest);
Now my question about this - what is the crucial reason that the top lines of code point to "readonly" and the bottom one works. Is this possibly just a "bug" or is there something behind it?
Thank you and have a pleasant day.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156