I have came across very interesting problem which I think it’s on Salesforce’s end but I would like to hear your thoughts on this.
If any of you used Formula Fields to bring a record type name from a particular record to another record might have seen this.
For an example I have record type called “Record Type X” on opportunity and “Record Type Y” on the account record.
When I use $RecordType.Name in the formula fields (RTNameAcc_c & RTNameOpp_c) on both records, the name of their record type is coming across correctly. However, the problem occurs when I reference the account record type on the opportunity record. If I create new formula field on the opportunity called AccountRTName__c and put the following formula Account.RTNameAcc__c instead of the related Account record type name (Record Type Y), I’m getting the opportunity record type name (Record Type X) instead.
I am aware that the formula in AccountRTName__c becomes Account.$RecordType.Name which is fine and should get the Account record type.
So my question is: Is it correct that when you use $RecordType in any context and formula field, the record type is referencing to parent object of the field? And if so, does anyone have a different solution to this problem (without using custom settings)?
Correct, the $ context variables are resolved in a non-intuitive way in this use case. It’s been a long time since I’ve dealt with this issue, but the solution I last saw was either a workflow field update on the source record or a trigger. Try the field update path, if that doesn’t work, you’ll probably need a trigger. I don’t think this issue has a purely formula-based solution, but as I said it’s been a while since I’ve dealt with it.