0

Good afternoon everyone!

I'm not a coder by any means, and I'm actually learning formulas and coding through the Salesforce Developer sandbox. So my question probably is an easy one.

I am trying to create a custom formula based on what a user picks in a pulldown menu. Depending on the length of a contract, and the start date of the contract, the output would be the expiration of said contract.

My question is, how can I make a formula where one of the pulldown options does not return a date, but returns text instead? When I try to output anything besides a date, Salesforce returns an error that it was not in a date format (since I picked date as the Formula Return Type)

IF (ISPICKVAL( Duration__c , "Indefinite"), "TEXT HERE" ,
IF (ISPICKVAL( Duration__c , "6 Months"), Date_Executed__c  + 183,
IF (ISPICKVAL( Duration__c , "1 Year"), Date_Executed__c  + 365,
IF (ISPICKVAL( Duration__c , "2 Years"), Date_Executed__c  + 730,
IF (ISPICKVAL( Duration__c , "3 Years"), Date_Executed__c  + 1095,
IF (ISPICKVAL( Duration__c , "5 Years"), Date_Executed__c  + 1825, Date_Executed__c
)
)
)
)
)
)

Thanks everyone!

1 Answer 1

0

You can change the formula field to a text formula field instead of a date formula field. Then, change the Date-Executed__c field to display as text.

IF (ISPICKVAL( Duration__c , "Indefinite"), "TEXT HERE" ,
IF (ISPICKVAL( Duration__c , "6 Months"), text(Date_Executed__c  + 183),
IF (ISPICKVAL( Duration__c , "1 Year"), text(Date_Executed__c  + 365),
IF (ISPICKVAL( Duration__c , "2 Years"), text(Date_Executed__c  + 730),
IF (ISPICKVAL( Duration__c , "3 Years"), text(Date_Executed__c  + 1095),
IF (ISPICKVAL( Duration__c , "5 Years"), text(Date_Executed__c  + 1825), text(Date_Executed__c)
)
)
)
)
)
)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .