+ Start a Discussion
RajashriRajashri 

Populate date based on checkbox

I want to populate the Systemdate(i.e Day date) in the current_Date_sys date field if my checkbox  sys_check is checked.

 

and if it's  unchecked then i  want to make the current_Date_sys field blank.

 

Can anyone guide me on this formula?

 

Best Answer chosen by Admin (Salesforce Developers) 
Jared KremerJared Kremer

Hey Raj,

 

I'm assuming you mean a field and an object and not a SystemDate field such as CreatedDate, which you cannot edit. 

 

To do this you can probably get away with a workflow. 

 

Settup -> App Setup -> Create -> Workflows & Approvals -> Workflow Rules

 

Create a new Workflow Rule On the object that you want to update the date on. 

 

Name your rule, Evaluation Criteria to Created, and any time it's edited to subsequently meet Criteria

 

Add your criteria for {Check_Box_Field__c} equals true.

 

Save and next,

 

Add a workflow action for new Field Update, name the Field update and set the field to update to be your date,

 

Use the Formula TODAY() for a Date and NOW() for a DateTime Field. 

 

likewise you can do the same things for when the record has criteria of the checkbox being false in a new rule and you can update the date field to NULL 

 

Is this what you needed?

All Answers

Jared KremerJared Kremer

Hey Raj,

 

I'm assuming you mean a field and an object and not a SystemDate field such as CreatedDate, which you cannot edit. 

 

To do this you can probably get away with a workflow. 

 

Settup -> App Setup -> Create -> Workflows & Approvals -> Workflow Rules

 

Create a new Workflow Rule On the object that you want to update the date on. 

 

Name your rule, Evaluation Criteria to Created, and any time it's edited to subsequently meet Criteria

 

Add your criteria for {Check_Box_Field__c} equals true.

 

Save and next,

 

Add a workflow action for new Field Update, name the Field update and set the field to update to be your date,

 

Use the Formula TODAY() for a Date and NOW() for a DateTime Field. 

 

likewise you can do the same things for when the record has criteria of the checkbox being false in a new rule and you can update the date field to NULL 

 

Is this what you needed?

This was selected as the best answer
RajashriRajashri

Thanks for the reply.

 

Here i am trying to write the validation rule on Date Field,

 

I have written the formula below

 

IF((Checkbox_Field__c = TRUE),TODAY(),NULL)

 

but i am getting the below error ,

 

Formula result is data type (Date), incompatible with expected data type (true or false)

 

can anyone please help

RajashriRajashri

Thanks a lot. Your way worked.but i want to locked the date field so that no one can change the date.I have make the checkbox read only through Edit Layout  but still it's editable.

 

is there any other way to make the date field read only?

RajashriRajashri

Got the solution for all queries! Thanks

Jared KremerJared Kremer

Sorry I was out of town and didnt reply back. Glad that worked for you!

LetteLette
Hello,
for users created in the past (before created this workflow) the date field is blank. So the formula doesn't work for fields filled in the past. 
How can I do to know the date when the ckeckbox was set to true? 
Any help will be appreciated :(