1

I'm trying this simple statement and getting null, shouldn't this be returning 1 since its a master-detail relationship? I've tried at API V40,41,42. Is my syntax wrong?

Here's the relevant documentation on DescribeFieldResult.

Anonymous script yielding null:

System.debug('relationshipOrder : ' + OpportunityLineItem.OpportunityId.getDescribe().getRelationshipOrder());

EDIT: My previous example was an attempt to make it more generic since not everyone has Work Orders enabled, my actual issue was with WorkOrderId on WorkOrderLineItem which is a MD relationship) also returning null.

https://imgur.com/eCTxjCV (screenshot of relationship)

WorkOrderLineItem.WorkOrderId.getDescribe().getRelationshipOrder() 

1 Answer 1

3

It's a Lookup relationship. The expected return value is null. Some standard objects allow Rollup Summary fields despite this configuration. See, for example, this delivered Idea:

Roll-up Summary Fields for Standard Objects (Opp-Opp Line in Winter 08)

The recently announced Summer 07 feature for Roll-up Summary fields is a great step forward. However, it only allows roll-up summaries to be created when a custom, master-detail relationship exists. It would be tremendously useful to extend that same functionality to standard objects and the existing relationships. For example...

Example 1
Create a Roll-up Summary field on the Account object that calculates the SUM of all related Opportunities where Stage = "Closed/Won." This is an obvious win for organizations that wish to easily identify the value of a particular customer in terms of sold business.

Example 2
Create a Roll-up Summary field on the Account object that calculates the COUNT of all related Cases where Type or Status = X. Use your imagination but this could be an easy way for support organizations to identify how many cases a customer has submitted versus their paid support agreement.

Example 3
Create a Roll-up Summary field on the Opportunity Product (line item) object that calculates the COUNT of all related Schedule Entries or the MIN/MAX date for related Schedule Entries. This would be an easy way to show - directly on the Opportunity related list for Products - how many monthly installments have been planned for a product or the first/last month that payment is expected.

6
  • oops well my actual issue is with: WorkOrderLineItem.WorkOrderId.getDescribe().getRelationshipOrder() I was just trying to create a more generic example.
    – Phil B
    Apr 9, 2018 at 19:33
  • any thoughts on why it would not work for WorkOrderId? I've verified that is a MD relationship
    – Phil B
    Apr 10, 2018 at 18:13
  • How did you verify? I thought there weren't any detail Standard Objects.
    – Adrian Larson
    Apr 10, 2018 at 18:22
  • It looks like the relationship between WorkOrder and WorkOrderLineItem is : imgur.com/eCTxjCV
    – Phil B
    Apr 10, 2018 at 18:26
  • Please edit that into your post instead. Might be that it only returns values for custom M-D, or maybe it's a bug. Hard to say.
    – Adrian Larson
    Apr 10, 2018 at 18:41

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.