In my last post I looked at how some of the core Sales entities are read-only in everything except their default state, and how you may need to go through a series of transitions between different states to edit them.
Although these are the only entities I’m aware of that are read-only in other states, there are some other examples of entities that can only be moved through a restricted set of state transitions rather than always being able to go directly from any state to any other.
Leads start in an Open state. You can move them to the Qualified or Disqualified states using an Update request, but if you want to change a Qualified lead to Disqualified or vice versa, you have to first change it back to Open.
Normally you’d use the QualifyLead request to change a lead to Qualified and optionally create the account, contact and/or opportunity records, but that is not required.
Similar to the lead entity, opportunities start in an Open state and can be moved to either Won or Lost. A Won or Lost opportunity has to be changed back to Open before changing to the other state.
You have to use the WinOpportunity or LoseOpportunity messages to change an opportunity’s state to Won or Lost, but you can use a regular Update message to change it back.
Cases follow the same pattern again, with records starting in the Active state and moving to either Resolved or Canceled. Resolving a case requires using the CloseIncident message, and all other transitions can use the standard Update message.
Cases are also the only standard entity that you can enable your own custom status transition restrictions.
It’s possible to add restrictions on how cases and your own custom entities can transition from one state to another. This can be helpful in guiding your users to the next appropriate state as well as enforcing specific business logic.
One thought on “MSDyn365 Internals: Restricted state transitions”