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
motumotu 

Adding a record type to a formula

Can someone help me figure out the right "grammar" for the following?  I need to create this formula only for one record type.  I have tried several formats without any success.

 

Thanks.

 

AND(

IF(

CASE( StageName , "Stage to be Required 1", 1, "Budgetary Quote Presented", 1, "Application Submitted", 1, "Application Completed", 1, "Quote/Prodef Completed", 1, "Samples Approved/Accepted", 1, "Customer Visit to FOBA", 1, "Finalizing Product Specifications", 1, "Negotiation/Review", 1, "Won Order, PO Pending", 1, "Closed Lost", 1, "Closed Won", 1, "Project on Hold", 1, "Project Identified and Qualified", 1, 0))

 

($RecordType.Id "01250000000DcDc",1,0))

Best Answer chosen by Admin (Salesforce Developers) 
motumotu

Well, for all of you that have been following this discussion, here is the solution:

 

IF (NOT(RecordTypeId="01250000000DcDc"), 0, CASE( StageName , "Stage to be Required 1", 1, "Budgetary Quote Presented", 1, "Application Submitted", 1,

"Application Completed", 1, "Quote/Prodef Completed", 1, "Samples Approved/Accepted", 1,

"Finalizing Product Specifications", 1, "Negotiation/Review", 1, "Won Order, PO Pending", 1,

"Closed Lost", 1, "Closed Won", 1, "Project on Hold", 1, "Project Identified and Qualified", 1, 0))

 

This is a custom formula field which is part ofan app on the appexchange that ensures that at least one primary contact role is added to an Opportunity. 

 

Thanks everyone for your input.

Message Edited by motu on 04-15-2009 08:33 AM

All Answers

Steve :-/Steve :-/

You should be okay with

 

 

RecordTypeId ="01250000000DcDc"

 

 

 

 

motumotu

Thanks for your response.  But, still having a problem.  I am using this for the solution you gave me to download Opportunity Primary Contact Rule from Appexchange.  Any idea on what I am doing wrong?  It gives me an error message that the field RecordType ID does not exist :

 

AND(
IF(

CASE( StageName , "Stage to be Required 1", 1, "Budgetary Quote Presented", 1, "Application Submitted", 1, "Application Completed", 1, "Quote/Prodef Completed", 1, "Samples Approved/Accepted", 1, "Customer Visit to FOBA", 1, "Finalizing Product Specifications", 1, "Negotiation/Review", 1, "Won Order, PO Pending", 1, "Closed Lost", 1, "Closed Won", 1, "Project on Hold", 1, "Project Identified and Qualified", 1, 0),

RecordType.Id =" 01250000000DcDc "))

Steve :-/Steve :-/
Which object are you trying to reference the RecordTypeID?  and which object are you doing this from?  The field name should be "RecordTypeId" (no dollar sign, or period)
motumotu

It is the Contact Required field (formula)from the Opportunity object.  Is below not correct?  It says I am missing a ")" but when I add, it gives me an error:  "Incorrect number of parameters for function IF(). Expected 3, received 2".  It does not see to like the AND(IF(

 

AND(
IF(

CASE( StageName , "Stage to be Required 1", 1, "Budgetary Quote Presented", 1, "Application Submitted", 1, "Application Completed", 1, "Quote/Prodef Completed", 1, "Samples Approved/Accepted", 1, "Customer Visit to FOBA", 1, "Finalizing Product Specifications", 1, "Negotiation/Review", 1, "Won Order, PO Pending", 1, "Closed Lost", 1, "Closed Won", 1, "Project on Hold", 1, "Project Identified and Qualified", 1, 0),

 RecordTypeId  =" 01250000000DcDc ")

 

Steve :-/Steve :-/
Can you re-post your code using the insert SourceCode button in the ToolBar?
motumotu

AND( IF( CASE( StageName , "Stage to be Required 1", 1, "Budgetary Quote Presented", 1, "Application Submitted", 1, "Application Completed", 1, "Quote/Prodef Completed", 1, "Samples Approved/Accepted", 1, "Customer Visit to FOBA", 1, "Finalizing Product Specifications", 1, "Negotiation/Review", 1, "Won Order, PO Pending", 1, "Closed Lost", 1, "Closed Won", 1, "Project on Hold", 1, "Project Identified and Qualified", 1, 0), RecordTypeId =" 01250000000DcDc "))

 

Thanks for the tip.  did not know what that icon was for!
Steve :-/Steve :-/

Here is a RecordTypeID formula that I used to require a Contact Type for a specific Contact Record Type (if the Account is a Client)

 

 

 

AND (ISPICKVAL(Account.Type, "Client"), (RecordTypeId ="012345678912345"), (Active__c = TRUE), NOT(ISPICKVAL(Contact_Type__c, "IT")), NOT(ISPICKVAL(Contact_Type__c , "Marketing")), NOT(ISPICKVAL(Contact_Type__c , "Procurement")), NOT(ISPICKVAL(Contact_Type__c , "Inactive")), NOT(ISPICKVAL(Contact_Type__c , "Billing")), NOT(ISPICKVAL(Contact_Type__c , "Executive")))

 


 

 

 

motumotu

Yes, tried something similar but got:  Error: Incorrect parameter for function AND(). Expected Boolean, received Number.  Sometimes formulas drive me CRAZY:smileymad: 

 

AND( (RecordTypeId =" 01250000000DcDc "), CASE( StageName , "Stage to be Required 1", 1, "Budgetary Quote Presented", 1, "Application Submitted", 1, "Application Completed", 1, "Quote/Prodef Completed", 1, "Samples Approved/Accepted", 1, "Customer Visit to FOBA", 1, "Finalizing Product Specifications", 1, "Negotiation/Review", 1, "Won Order, PO Pending", 1, "Closed Lost", 1, "Closed Won", 1, "Project on Hold", 1, "Project Identified and Qualified", 1, 0))

 

rpr2rpr2

Try removing the spaces that you have at the start and end of the record type ID  

 

In other words, use

(RecordTypeId ="01250000000DcDc"), instead of (RecordTypeId =" 01250000000DcDc "),

 

 

and see whether that resolves the issue.

Message Edited by rpr2 on 03-29-2009 10:54 PM
KevinLoveKevinLove

I think you have the syntax wrong on your AND statement. What is it you trying to achieve with this formula? It may be easier to help you if you describe in fine detail what you want your result to be and where it will be used(display a value or for field validation) and to use some psuedo code when describing the formula.

 

Happy Monday!

motumotu
This was an App from AppExchange which enforces a user to add a Contact to an Opportunity for all Stages except for "Open".  I need to enforce it for my Record Type only.  To do this, the application creates a formula field on the Opportunity page and a bunch of Apex Code that is beyond me.  Unfortunately, Validation rules will not work.  I really just wanted to ensure there is a contact to an account that has an Opportunity or simpler still, a contact to an account that is a prospect or a customer.
crop1645crop1645

I recommend where possible to use $RecordType.Name as the formula will then port between your PROD and Sandbox instance.

 

Example from one of my apps: IF($RecordType.Name = 'Discount', Extended_Price__c * (-1.00), Extended_Price__c )

motumotu

Well, for all of you that have been following this discussion, here is the solution:

 

IF (NOT(RecordTypeId="01250000000DcDc"), 0, CASE( StageName , "Stage to be Required 1", 1, "Budgetary Quote Presented", 1, "Application Submitted", 1,

"Application Completed", 1, "Quote/Prodef Completed", 1, "Samples Approved/Accepted", 1,

"Finalizing Product Specifications", 1, "Negotiation/Review", 1, "Won Order, PO Pending", 1,

"Closed Lost", 1, "Closed Won", 1, "Project on Hold", 1, "Project Identified and Qualified", 1, 0))

 

This is a custom formula field which is part ofan app on the appexchange that ensures that at least one primary contact role is added to an Opportunity. 

 

Thanks everyone for your input.

Message Edited by motu on 04-15-2009 08:33 AM
This was selected as the best answer