1

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?

  • In your text are a lot of typing errors. I tried to fix some but now I come to your field names and you should do this by yourself: ob2 vs. obj_2 and ob1_r probably should be ob1__r. Your post is very hard to read. – Uwe Heim Sep 28 '14 at 7:43
2

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.

2

You can accomplish this by using the BLANKVALUE() function. Below should work for you.

BLANKVALUE(ob2__r.descrip__c, ob3__r.descrip__c)

What this does is look at ob2__r.descrip__c, if there is a value and it isn't null, it returns that, if not, it returns ob3__r.descrip__c.

You can check out this function and many more in the docs below

https://help.salesforce.com/apex/HTViewHelpDoc?id=customize_functions_a_h.htm&language=en_US#BLANKVALUE

  • Does this work if I want to check if a parent record has a child record? I basically want to create a formula field which populates true or false based on certain conditions on the parent AND whether that parent has a child record? – Ali Gajani Jun 11 '18 at 8:53

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.