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
kmurphy.ax1526kmurphy.ax1526 

One field with two different formulas depending on the record type.

Wondering if this is possible.

 

I have several opportunity record types and on all of them I have a field called "New Business". The is a formula field. I am wondering if on a specific record type I can change the formula without having to create a new field to do this. I would like to use the same "New Business" field on all my record types but have it calculate different on a specific record type.

 

Thanks,

Katelyn

Best Answer chosen by Admin (Salesforce Developers) 
Shailesh DeshpandeShailesh Deshpande
That is because the IF function takes 3 parameters and you have just provided 2.

the way IF works is as below:

IF(
your condition,
do something if condition = true,
do something if condition = false
)

All Answers

Jeff MayJeff May

You can use IF() in the formula and check the Record Type.

 

IF(RecordtypeA, 1 + 1, 1 * 4)

Shailesh DeshpandeShailesh Deshpande
As Jeff said, you'll need to use If() function to achieve this. As you have many recordtypes, you will need nested if().

IF(recordtypeA, value A, IF(recordtypeB, valueB, valueC))
kmurphy.ax1526kmurphy.ax1526
Thank you, Can you see this image [cid:image003.jpg@01CE02E2.413463E0] I am having trouble with syntax on the record type name? How do I enter the correct record type name? I tried $RecordType.Name ( for the Name i entered the api text and i get a syntax error. I must be doing this wrong. thanks, Katelyn
Jeff MayJeff May

I can't see the pictures, but here are some comments.

 

The Opportunity Record has a 'Record Type ID' field that you can use.  (To find the Record Type ID, go to the Opportunity Record Types page under Setup.  Click on the Edit link next to a record type, and look at the URL in the browser bar -- you'll see an id=.......&   The ID is between the id= and the next &.

 

Once you have the ID, your field formula can look like this:

 

IF(RecordType = '012G000000129p4',  1 + 1, 1 *4)

 

To use the Name instead, I think you can create a formula field on the Opportunity with a formula of 

$RecordType.Name

 

Then, your original formula field could be:

 

IF(myRecNameField  = 'Special Opps',  1 + 1, 1 *4)

 

 

 

 

 

kmurphy.ax1526kmurphy.ax1526

Thank you! I keep getting a syntax error that says: Incorrect number of parameters for function 'IF()'. Expected 3, received 2

 

This is my formula

 

ACV_Year_1__c+ACV_Year_2__c+ACV_Year_3__c+ACV_Year_4__c+ACV_Year_5__c+ACV_Year_6__c+Total_Implementation_Charges__c+  IF(ID='012R00000004s8K', Customer_Per_Key_Fee__c *  Keys_Year_1__c)

 

Starting at IF I have: IF(ID='012R00000004s8K', Customer_Per_Key_Fee__c *  Keys_Year_1__c)

 

The ID is the record type ID. If the Record type has a particular type then I want a different calculation for that field. So above I have my record type ID and then I multiply "Customer_Per_Key_Fee__c *  Keys_Year_1__c"

 

 

 

 

Shailesh DeshpandeShailesh Deshpande
That is because the IF function takes 3 parameters and you have just provided 2.

the way IF works is as below:

IF(
your condition,
do something if condition = true,
do something if condition = false
)
This was selected as the best answer