• manibharathi v
  • NEWBIE
  • 0 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 3
    Replies
Hey,

I have a Custom object (custom_object__c) with a Lookup field for (Contact) from which I would like to get a field or custom field from a standard object (ie. Contact). If I understood correctly I then need to do a Child - Parent relationship which is in the form of dot notation.

So here is my code:

public static List<custom_object__c> getStudents(){
        LIST<custom_object__c> students = [SELECT 
                Id, 
                Name,
                Contact__r.custom_field__c,
                 custom_object__c__custom_field_1,
                custom_object__c__custom_field_1
                FROM custom_object__c
                LIMIT 100
                OFFSET 0];
        
        return students;
    }

And here is the error message:

Didn't understand relationship 'Contact__r' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.

Any explanation is greatly appreciated, thank you.
 
Hi,

I am trying to build a formula field (number) to track to number of opportunities of a certain type that contain a certain product. I have a field called "Type of Sale" (picklist) that we use to track the type of sales we make (Serialization, Serialization and aggregation, Inspection, etc). I want to create a field that will look at that field and if it has a certain value (Serialization OR Serialization and aggregation) AND a certain product (BottleTracker OR CartonTracker OR Flying CartonTracker OR Manual Print Station OR PackStation CAP OR PacStation SAP OR PackStation SAP OR LabelTracker OR BunderTracker) is attached to the opportunity, the field value will be 1. If not, it will be 0. I will then use that field to report of the % of Serialization AND Serialization and aggregation sales that include the aforementioned products.

I have came up with the following formula:

IF(AND(OR(Type_of_Sale__c="Serialization", Type_of_Sale__C="Serialization and aggreation"), (OR(PricebookEntry.Product2.Name="BottleTracker", PricebookEntry.Product2.Name="CartonTracker", PricebookEntry.Product2.Name="Manual Print Station", PricebookEntry.Product2.Name="PackStation CAP", PricebookEntry.Product2.Name="PackStation FMP", PricebookEntry.Product2.Name="PackStation SAP", PricebookEntry.Product2.Name="BundleTracker", PricebookEntry.Product2.Name="LabelTracker")), 1, 0))

When I use the "check syntax" button, the syntax is fine, but it tells me that "Picklist fields are only supported in certain functions".

How should I proceed to achieve my goal? I have absolutely no experience with advanced formulas so please dumb it down to my level.