0

I have always the same problem when I use apex: repeat

the question is how or where do we find/write the API name for a plural Label .

I had the same case before with BC (Purchase order) and BC Line Items : 2 objects that I have created .

after testing I found the solution here : BC case

on the BC Object where API Name: BC__c Plural Label : BC (Purch. Orders) on the BC Line item Object , we have on Custom fields : BC ( BC_c) as a

Master-Detail(BC (Purch. Order))

and

Plural Label : BC Line Items API Name BC_Line_Item__c

so following the solution on the first link The apex repeat works after doing :

 <apex:repeat var="opp" value="{!relatedTo.BC_line_items__r}">  </apex:repeat> 

now my problem is on Sales Order Level and Sales Order Linte Item . Plural Label : Sales Orders API Name Sales_Order__c

and on sales Order Line Item :

Plural Label    Sales Order Line Items
API Name    Sales_Order_Line_Item__c

Sales Order (Sales_Order__c) Master-Detail(Sales Order)

when I tested it in different way by writing :

<apex:repeat var="opp" value="{!relatedTo.Sales_order_line_items__r}">

or <apex:repeat var="opp" value="{!relatedTo.Sales_Order_Line_Item__r}">

there is an error Error: Invalid field Sales_order_line_items__r for SObject Sales_Order__c

thanks in advance for your response

  • it's just master detail relationship API. – Parth Thakkar Jul 21 '15 at 10:16
  • Hi , do you mean on Master-Detail Options on Sales Order Line item Object . when I checked Master-Detail(Sales Order) : API Name : Sales_Order__c and on the option Related List Label : Sales Order Line Items – Julio Ludovic Ramihone Jul 21 '15 at 10:23
  • A standard object gets an s appended to its name. A custom object would get the __r depending on the context. If someplace in your code, you've isolated the object to where it's now purely that object, it then goes back to __c, but if you're iterating from a query on the original object and it's a related object, it would have the __r. – crmprogdev Jul 21 '15 at 14:32
2

For custom lookup fields, the developer chooses the name for the relationship. To find the name, look at the field details for the lookup. The property is called the relationship name. It will not include the __r, but you need to include it when referencing the relationship.

| improve this answer | |

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.