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.
ShowAll Questionssorted byDate Posted sfdc-admin-sm

# Trying to populate a date field by a workflow field update

Hello,

I need some help.

I am trying to automatically populate a date fieId (Expiration_Date__c) by a workflow field update based on multiple values of the Term field (Term__c)

So for example,

If Term__c  = 1 then the Expiration_Date__c = Start_Date__c + 1 month

If Term__c  = 6 then the Expiration_Date__c = Start_Date__c + 6 months

If Term__c  = 12 then the Expiration_Date__c = Start_Date__c + 12 months

If Term__c  = 24 then the Expiration_Date__c = Start_Date__c + 24 months

Thanks, Best Answer chosen by Admin (Salesforce Developers)  Venkat Polisetti

@saravanan is right. You will need to use one of those functions. Looks like you need to learn to write SF formulas.

CASE( term__c,
1, Start_Date__c + (1 * 30),
6, Start_Date__c + (6 * 30),
12, Start_Date__c + (12 * 30),
Start_Date__c + (24 * 30))

Salesforce does not have a formula function to add months to a date. You can only add days. You can find a custom formula to add months in these boards, but that would definitely exceed your compile size of your formula.

Hope this helps,

Thanks, Saravanan @Creation

Hi

Please refer the CASE() function on the formula. sfdc-admin-sm Venkat Polisetti

@saravanan is right. You will need to use one of those functions. Looks like you need to learn to write SF formulas.

CASE( term__c,
1, Start_Date__c + (1 * 30),
6, Start_Date__c + (6 * 30),
12, Start_Date__c + (12 * 30),
Start_Date__c + (24 * 30))

Salesforce does not have a formula function to add months to a date. You can only add days. You can find a custom formula to add months in these boards, but that would definitely exceed your compile size of your formula.