1

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 categorised 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.

After running the apex code below

Schema.DescribeFieldResult stCodeDesc = Order.StatusCode.getDescribe();
System.debug('Order.StatusCode');
System.debug('isCreateable? '+stCodeDesc.isCreateable());
System.debug('isNillable? '+stCodeDesc.isNillable());
System.debug('isCalculated? '+stCodeDesc.isCalculated());

we got this DEBUG output:

11:19:39:003 USER_DEBUG [2]|DEBUG|Order.StatusCode
11:19:39:004 USER_DEBUG [3]|DEBUG|isCreateable? false
11:19:39:004 USER_DEBUG [4]|DEBUG|isNillable? false
11:19:39:004 USER_DEBUG [5]|DEBUG|isCalculated? false

Question: How the StatusCode field is populated behind the scenes? With a custom code (outside salesforce) for validating the records creation before calling the API, we validate user inputs and as StatusCode is mandatory in theory (isNillable=false), so we put it as mandatory, and when a value is put for StatusCode I got the error:

Unable to create/update fields: StatusCode. Please check the security settings of this field and verify that it is read/write for your profile or permission set.

I believe that it is because of the field is not Createable, I just want to understand why this field is not a Calculated field from a technical perspective.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.