[SalesForce] How to get lookup field values from the formula field

Can we get the parent field value by comparision in the formula field?
a object has two parents.
we need to get that two parent value in formula field but the
condition is. need to check the first parent, whether the value is null or not, if null get the second parent field value.

object names:

ob1

lookup fields:
ob2 (field name is descrip)
ob3 (field name is descrip)

i have tried liek below:

if( ob1_r.desc != null, value, obj_2.descrip);

above is right?

Best Answer

From your question I understand you require a formula field which will be populated based on the field named 'desc' present in both the parents. Also it should check if the field 'desc' is empty before using it.

  • Let the parent objects be Parent1__c and Parent2__c and the child be Child__c.
  • Parent1__c has a field named Desc1__c and Parent2__c has a field named Desc2__c.
  • Child__c has a formula field named Desc__c.
  • Formula for this child field Desc__c with return type Text will be like this:

IF( ISBLANK(Parent1__r.Desc1__c), Parent2__r.Desc2__c , Parent1__r.Desc1__c)

The above formula will check if Parent1__c object's Desc1__c field is blank or not. If blank then Parent2__c object's Desc2__c will be populated in the child object else Parent1__c object's Desc1__c will be populated.

I hope this helps.

Related Topic