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
k sfdck sfdc 

How to update a field when i click checkbox using trigger?

Hi,
       I have one  Cancel__c(checkbox) on  custom object.Whenever this checkbox gets checked, a trigger should fire and update the Discount percentage field to 70% How?

please help me.....
Fabien TaillonFabien Taillon
On save, you should use workflow (setup) instead of trigger:
https://help.salesforce.com/HTViewHelpDoc?id=creating_workflow_rules.htm

You can find some examples here:
https://org62.my.salesforce.com/help/pdfs/en/salesforce_useful_workflow_rules.pdf

k sfdck sfdc
Hi Fab,
              Using trigger not workflow rule.

please help me..........
Fabien TaillonFabien Taillon
Why do you want to use trigger ? 
k sfdck sfdc
Hi,
      This is my requirement

Whenever this checkbox gets checked, a trigger should fire and update the Discount percentage field to 70% How?
Prem_PalPrem_Pal
Why don't you invoke a function on click of checkbox and update your record.
Fabien TaillonFabien Taillon
Maybe you should challenge your requirement. This is not a Salesforce best pratice to use custom code whereas you could use a workflow.
Maybe the guy that asked you about the trigger doesn't know about workflows.
Prem_PalPrem_Pal
I agree with Fab. Please verify your requirement once again.
k sfdck sfdc
Thank you Fab  and Prem_Pal now i am a trinee that's why they asked