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
ChrisColeChrisCole 

Formula to pull Opportunity RecordType data from a custom object

I am having trouble pulling Opportuntiy related data into a custom formula field (Lifecycle_Phase__c) that I created in my custom Engagement object.

 

On my custom Engagement object, I have a look-up field to Opportunity. I am trying to grab the recordtype info (RecordTypeName__c - which just converts the long RecordTypeId number to the Name) and place it in the above mentioned custom formula field in Engagement named "Lifecycle Phase."

 

I wrote both a CASE formula and a nested IF formula but in both instances, all that gets pulled is the "else" variable "Cross Lifecycle."

 

I have copied both formulas below - what am I missing. I get no actual syntax errors. Any help would be greatly appreciated.

Thanks!

 

CASE(Opportunity__r.Opp_RecordTypeName__c , "Design Phase", "Design", "Transition Phase", "Transition", "Operate Phase", "Operate", "Cross-Lifecycle")

 

IF(Opportunity__r.Opp_RecordTypeName__c = "Design Phase", "Design", 
IF(Opportunity__r.Opp_RecordTypeName__c = "Transition Phase", "Transition",
 IF(Opportunity__r.Opp_RecordTypeName__c = "Operate Phase", "Operate", "Cross Lifecycle")))

Best Answer chosen by Admin (Salesforce Developers) 
Madhan Raja MMadhan Raja M

Hi Chris,

 

How did you get the Opportunity Record Type ID's?

 

Customize > Opportunity > Record Types > Click on 'Design Phase' Record Type Label and you will find the 15 characters ID for 'Design Phase' record Type from URL.

 

 

Please post your formula If the issue has not resolved.

 

Madhan Raja M

All Answers

Madhan Raja MMadhan Raja M

Hi Chris,

 

Your formula is correct! The problem is in your Opp_RecordTypeName__c field. How did you populate the Record Type name in Opp_RecordTypeName__c field?

 

Madhan Raja M

matermortsmatermorts
The case formula should probably work but I would have taken a slightly different approach. See below.

CASE (
Opportunity__r.RecordType.Name,
"Design Phase", "Design",
"Transition Phase", "Transition",
"Operate Phase", "Operate",
"Cross-Lifecycle"
)
ChrisColeChrisCole

Thanks for your reply. I have a custom formula field in Opportunity that simply contains "$RecordType.Name" - so I won't have to use the 16 digit RecordTypeId. I saw it on a board and it works great. I tested the field, and it does in fact contain the RecordTypeId name. I just can't pull it form my case statement.

ChrisColeChrisCole

Thanks very much fro your suggestion. I tried it and still no luck. With the suggested statement, I get a syntax error telling me there is no "RecordType" field. I tried RecordTypeId.Name, too.

 

I'm open to a slightly different (or even completely different) approach if you have one....

Thanks!

Chris

Madhan Raja MMadhan Raja M

The issue is with "$RecordType.Name". "$RecordType.Name" gets the current object Record Type name.

 

Try this formula:

 

IF(Opportunity__r.RecordTypeId  = "012900000008EjL", "Design",
IF(Opportunity__r.RecordTypeId  = "012900000008El2", "Transition",
IF(Opportunity__r.RecordTypeId  = "012900000008El3", "Operate", "Cross Lifecycle")))

 

Replace "012900000008EjL" with your "Design Phase" Record Type ID

Replace "012900000008El2" with your "Transition Phase" Record Type ID

Replace "012900000008El3" with your "Operate Phase" Record Type ID

 

Opp_RecordTypeName__c field is not required.

 

If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.

 

Madhan Raja M

ChrisColeChrisCole

Thank you again Madhan for your response.

 

This is crazy. Here I thought that this would be fairly straightforward and I still can't get it to work. I tried the new IF statement with my RecordTypeIds and still it defaults to Cross Lifecycle when the Oppty I'm associating is (absolutely) Design.

 

I've triple checked my RecordTypeIds, made sure the test record type(s) is in fact "Design Phase," etc.... but it always comes up as Cross Lifeclye.

 

There must be something very fundamental that I'm missing here. Is there something I should be telling/showing you that I'm not? Could my Oppty look-up field not be right somehow?

 

I know that the Oppty is successfully being associated with the Engagement because the Engagement shows up in the Engagement Related List on the Oppty.

 

Thanks again for your time. I thought I'd try to figure this out before Hurricane Sandy (potentailly) knocks out my Internet connection (not a drop of  rain or wind so far, though). Otherwise, talk to you in a couple days.

 

Regards,

Chris

Madhan Raja MMadhan Raja M

Hi Chris,

 

How did you get the Opportunity Record Type ID's?

 

Customize > Opportunity > Record Types > Click on 'Design Phase' Record Type Label and you will find the 15 characters ID for 'Design Phase' record Type from URL.

 

 

Please post your formula If the issue has not resolved.

 

Madhan Raja M

This was selected as the best answer
ChrisColeChrisCole

Madhan,

Copying the RecordType from the URL worked.

THANK YOU! I got the RecordTypeIds by exporting them from the RecordType table using Data Loader. I never notied that they have extra characters on them.... I used those same RecordType Ids in a script for a third party application integration and they worked fine. I wonder what the extra charaters do?

Thanks Again,

Chris

 

Madhan Raja MMadhan Raja M

Hi Chris,

 

15 characters ID is case-sensitive and 18 characters ID is case-insensitive. Data Loader gives us 18 characters ID.

 

Madhan Raja M

ChrisColeChrisCole

Thanks! I still have so much to learn.