The standard Order object has a Status picklist field defined as follows:

Picklist of values that indicate order status. Each value is within one of two status categories defined in StatusCode. For example, the status picklist might contain Draft, Ready for Review, and Ready for Activation values with a StatusCode of Draft.

There is also a StatusCode (Status Category) field defined as follows:

The status category for the order. An order can be either Draft or Activated. Label is Status Category.

Each Status is categorized as being a Draft status or an Activated status. (This is similar to Opportunity Stages being classified as Won / Closed (IsWon).)

The documentation states that the Order can be activated by setting the Status field to an Activated state:

The application can subsequently activate an order by updating it and setting the value in its Status field to an Activated state; however, the Status field is the only field you can update when activating the order.


How can I programmatically determine if a Status picklist entry value is an Activated or Draft Status, so that I can use it to activate the order?

I do not want to do something that requires referencing the status String such as the following since it is not super robust or portable.

order.Status = 'Activated';

2 Answers 2


There is no way to programmatically get a specific status that is has a Status Category (StatusCode) of Activated ('A') or Draft ('D').

If you don't care about the specific status but just that you are assigning an Activated or Draft status then there is a hack that you can implement (a co-worker of mine came up with).

The hack is to iterate over the picklist values from the Order.Status field's describe and assign them to dummy Orders, insert the Orders with Database.insert(dummyOrders, false).. The ones that insert successfully will be 'D'raft StatusCodes since you can only insert Orders with a Draft status. The ones that fail will be 'A'ctivated statuses.

It is a hack for sure, but has worked for us in our unit tests when we need to create an Order in a Draft status or Activate an Order as part of a unit test and don't want to use hardcoded values, custom labels, etc.

  • I've accepted my own answer as a workaround, for now. Hopefully something better comes a long and then I'll accept that answer. Oct 23, 2014 at 13:52
  • ...I've just developed a code set the status ='Draft' and it works. Is there any implication of using that? orderrec.Status = 'Draft'; update orderrec;
    – Ayub
    May 10, 2018 at 10:12

It would appear that that data isn't currently available, at least it's not in the latest object reference where i could find it.

For most objects with special picklists there is a corresponding object you can use to query the values with their related metadata. For example the ContractStatus object stores the StatusCode of Draft, InApproval, Activated for each picklist value.

You might just try OrderStatus and see if that works, otherwise I'd recommend contacting support to see about when that object will be available.

  • There is a corresponding StatusCode (label Status Category) which will have the value of 'A' when an Order is activated, but to activate an Order the Apex must set the Status field to an activated status (setting the StatusCode to 'A' doesn't activate). Problem is, how to know which statuses are activated statuses programmatically (was hoping there'd be something in Describe or some other API). Jul 2, 2014 at 10:50
  • @PeterKnolle correct, it wouldn't be in describe, but would be in a separate object, e.g. for contracts you'd query Select MasterLabel FROM ContractStatus WHERE StatusCode = 'Activated'. However that doesn't appear to be possible for Orders (at least it's not in the object reference). I'd suggest asking support Jul 2, 2014 at 20:16
  • @Raplh - Ah. I understand, now. Thanks. That would be ideal. I'll contact support. Jul 2, 2014 at 20:44
  • Let us know what you find. And in case you're curious, there are a ton of these, e.g. OpportunityStage, CaseStatus, LeadStatus, and a bunch more ... Jul 2, 2014 at 20:47
  • Spoke with someone from Salesforce.com (very grateful to be able to do that).. There does not appear to be a way at this time to do it. There isn't anything like the ContractStatus. So, hopefully, a way for it to be done will come out in an upcoming release, since they obviously have a way to do it, but it just isn't exposed. Sep 13, 2014 at 1:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .