function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
vsabbellavsabbella 

Need help with formula field

I have custom object which is a child of Opportunity Object through a master detail relation ship.

 

I want to get the recordtype name of Opportunity on the child custom object record.

 

Formula on Opportunity Fied(Opp_rec_name__c):$ recordtype.name

 

Formula on Custom Object(child):Opportunity__r.Opp_rec_name__c. Do a formula field like print the current Child Object record type name. Not the Opportunity record type name.

 

I do not want  to use the trigger to print the parent object record type name on the child object.

 

Is there any other way I can print the name???

 

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Shannon HaleShannon Hale

$RecordType.Name will always return the record type of the current record. In Spring '13 Salesforce deprecated it, and it shouldn't be used in new formulas.

 

What you'll want to do is use in Opp_rec_name__c is the Record Type reference on the Opportunity itself, so it will be:

 

RecordType.Name

 You won't need to change the field on the child custom object.

 

For more information, see the "Referencing Record Types in Formulas" section in the Tips on Building Formulas help topic: http://help.salesforce.com/help/doc/en/tips_on_building_formulas.htm

All Answers

Shannon HaleShannon Hale

$RecordType.Name will always return the record type of the current record. In Spring '13 Salesforce deprecated it, and it shouldn't be used in new formulas.

 

What you'll want to do is use in Opp_rec_name__c is the Record Type reference on the Opportunity itself, so it will be:

 

RecordType.Name

 You won't need to change the field on the child custom object.

 

For more information, see the "Referencing Record Types in Formulas" section in the Tips on Building Formulas help topic: http://help.salesforce.com/help/doc/en/tips_on_building_formulas.htm

This was selected as the best answer
vsabbellavsabbella

Thanks for the reply Shannon. I remember I tried using the recordtype reference recordtype.name in validation/formula fields. I did not work.

 

It is working like a charm now.

Does it have something to do with the subsequent releases??

 

 

Anyhow thanks a lot.

 

 

 

Shannon HaleShannon Hale
Yes - we only started supporting it in Spring '13, so it's only been available for a few months.

There's no need to change existing $RecordType formulas if they are working for you already, but going forward, plan to use RecordType instead.
vsabbellavsabbella
Excellent. That simplifies the apex coding a lot. Earlier I happened to write a trigger for that small recordtype update. From now I will not!!!

Thanks.