I Have two custom objects(obj1 and obj2) and two fields(Obj1field and Obj2field) in these custom objects.Now I would like to write a validation rule in obj1, which compares the two fields.I tried the below one, but there is an error.

Enter_Required_Quanity__c >=    $ObjectType.StorageObject__c.Fields.Quantity_Left__c 

When I tried this the following error occurred.

Error: Incorrect parameter type for operator '>='. Expected Number, received Object

  • 1
    You can do the validation against two records (your current record obj1 and its parent - lookup field to obj2)
    – Kevan
    Commented Feb 25, 2017 at 10:23
  • Can you please share any steps
    – venkatesh
    Commented Feb 25, 2017 at 11:21
  • Is there any relationship between obj1 and obj2
    – Samir
    Commented Feb 25, 2017 at 11:28

1 Answer 1


First of all, the Validation Rule executes upon a DML event on an object. For argument's sake, we'll assume that object is Obj1__c

So, as long as Obj2__c is a parent object (via master-detail or lookup) to Obj1__c, then the Validation Rule would look like

Enter_Required_Quantity__c > Obj2__r.Quantity_Left__c

Obj2__r is the relationship name from Obj1__c to Obj2__c

Now, if Obj2__c is not related to Obj1__c via a master or lookup relationship (parent/grandparent/great-grandparent or greatgreat-grandparent), then you can't do the Validation Rule.

Validation Rules can't look down to children nor look up and then down to siblings.

  • But here I need to click on lookup to select the record.
    – venkatesh
    Commented Feb 27, 2017 at 6:37
  • @Peeter6264 - please use the edit link on your OP to amend your question with more details as it would appear I misunderstood your question
    – cropredy
    Commented Feb 27, 2017 at 19:36

You must log in to answer this question.

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