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
Julie Steinloski 5Julie Steinloski 5 

Need to combine two formulas into one on Opportunity custom field

I have a formula field where I need to return varying values based upon an opportunity with or without a related campaign.  IF my opporunity has NO campaigns, I need to use this forumla.  

Scenario ONE has no syntax errors:

IF(CampaignId  = null &&  CustomField__c <> null, "Value 1", "Value 2")

If my opportunity has a campaign, I need to add this logic:

Scenario TWO has no syntax errors:

CASE(
Campaign.Type,
"Direct Mail","Direct Mail",
"Email","Email",
"Trade Show","Trade Show",
""
)

I'm trying
 

CASE(
CampaignId  = null &&  CustomField__c <> null, "Value 1", "Value 2"),
Campaign.Type,
"Direct Mail","Direct Mail",
"Email","Email",
"Trade Show","Trade Show",
""
)
)

Error: Syntax error. Extra ','

Raj VakatiRaj Vakati
Try this
 
IF ( CampaignId==NULL , 
IF(CampaignId  = null &&  CustomField__c <> null, "Value 1", "Value 2") , 
CASE(
 Campaign.Type,
"Direct Mail","Direct Mail",
"Email","Email",
"Trade Show","Trade Show",
""
)
)

 
Abdul KhatriAbdul Khatri
Please try this ISBLANK takes care of NULL and Spaces too
 
IF ( ISBLANK (CampaignId) , 
	IF ( NOT ( ISBLANK(CustomField__c ) ), "Value1", "Value2"  ), 
	CASE ( Campaign.Type,
		"Direct Mail","Direct Mail",
		"Email","Email",
		"Trade Show","Trade Show",
		""
	)
)

 
Julie Steinloski 5Julie Steinloski 5
This did the trick!  Thanks so much Abdul!  @Raj ... I didn't get a chance to try yours since Abdul's worked.  Thanks for your input.
 
Abdul KhatriAbdul Khatri
Can you be so kind to mark the best answer? Thanks.