0

I created a custom field called Start_Date of type date. I created another field called End_Date that I would like to default to Start_Date + 6 months. But whenever I try to do this in a formula I get the error: "Field Start_Date__c may not be used in this type of formula".

This is the formula I tried:

ADDMONTHS(Start_Date__c,6)

Any ideas on what I'm doing wrong?

  • 2
    Make sure you have same data type for the Formula field(End Date) as well, i.e., Date. – Arnold Jr. Jul 24 '18 at 19:46
  • Thanks for the help. Both Start_Date__C and End_Date__c are date fields. Any other thoughts on what it could be? – John M Jul 25 '18 at 14:52
1

I have replicated the same requirement on my Developer edition and it seems to be working as expected. What I have done:

  1. Start Date: startDateField
  2. End Date: This is of data type: Formula and return type: Date EndDateField
  3. Formula on End Date field: Formula
  4. Test Case Record:

    Sample

Note: Just make sure you/user profile have the necessary FLS for the field: Start_Date__c before trying to access it while creating the End_Date__c formula field. Hope this helps.

| improve this answer | |
  • Ah, that was my problem I had End Date set to data type Date. I have one other issue now. I would like this to be defaulted to the 6 months out, but I want to make the field user-editable. Is this possible using a formula field or through another method? – John M Jul 25 '18 at 16:06
  • Formula fields are auto-generated(based on criteria) and cannot be edited. So you might consider doing this: You might need to create one more field(lets say: End_Date_Changeable__c) to auto-populate(using a Workflow/Process builder) it's value from the above Formula field(End_Date__c). Make sure your workflow should evaluate only at the "On Creation" – Arnold Jr. Jul 25 '18 at 16:14
  • Yep it's working now. Hid the formula field and the user is able to edit the End Date field that is visible. Thanks for the help! – John M Jul 25 '18 at 17:05
0

The format for ADDMONTHS is correct. You most likely selected the wrong data type for the End_Date formula. Verify that the formula is data type date and not some other data type. Also, I pasted a link to salesforce documentation regarding formulas if you need a reference.

https://help.salesforce.com/articleView?id=customize_functions_a_h.htm&type=5

| improve this answer | |
  • Thanks for the help. Both Start_Date__C and End_Date__c are date fields. Any other thoughts on what it could be? – John M Jul 25 '18 at 14:52
0

Start_Date__c should be of field type Date. The error message mentions the same.

Change the Field Type of Start_Date__c

| improve this answer | |
  • Thanks for the help. Both Start_Date__C and End_Date__c are date fields. Any other thoughts on what it could be? – John M Jul 25 '18 at 14:49
  • As confirmed by you, this was the issue. – sfdcFanBoy Jul 26 '18 at 4:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.