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
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 :(
Airtel Limited 63Airtel Limited 63
i have one field in salesforce "Coordinator´s validation" which is a checkbox. want to create another formula field "Coordinator´s validation date" where it will automatically populate the date of when the checkbox "Coordinator´s validation" is checked. how will be the formula this formula will not work ":IF(Coordinator_s_validation__c, TODAY(), NULL)" because every time when i will update the record then the date will be update. plz suggest.