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
Ian GendreauIan Gendreau 

Create an action to run on command

Total Apex newbie here, but here is what i need.  Hopingn someone can point me in the right direction to start.
If I want to run an action on my Contact records all at once, what's the best way to make that happen? Specifics...
Each Contact record has a custom check box and a custom date field.
I want to be able to "tell" the system to find all records where the checkbox is checked, clear it out, and add today's date to the date field for those records. I want to be able to do that on an "on demand" basis, not a one time thing. 

Is that possible? And if so, where would I begin? 
Terence_ChiuTerence_Chiu
You can probably automate this action using Workflow rules (https://help.salesforce.com/apex/HTViewHelpDoc?id=creating_workflow_rules.htm) or via Process Builder (https://help.salesforce.com/HTViewHelpDoc?id=process_overview.htm). Both routes will allow you to detect if the contact record's checkbox field has been checked, clear the field then update the date field with today's date. This will alleviate any need for Apex as with the workflow rule or process builder flow will facilitate the update the record if the record meets the evaluation criteria.

However, if you must create an on-demand functionality you can try building a custom interface with Visualforce and an Apex controller class. Below link should get your started.

https://developer.salesforce.com/page/An_Introduction_to_Visualforce