You need to sign in to do that
Don't have an account?

how to write an apex call to update a field on the lead object
Hello,
I am new to APEX so thanks in advance for helping a newbie out.
I need an APEX to run at midnight (I will use the SF scheduler) to update a custom field (whatever__c) with a number (42). My end goal is to have this field update (whatever__c = 42) will kickoff a process I created in process builder.
Thanks again everyone
I am new to APEX so thanks in advance for helping a newbie out.
I need an APEX to run at midnight (I will use the SF scheduler) to update a custom field (whatever__c) with a number (42). My end goal is to have this field update (whatever__c = 42) will kickoff a process I created in process builder.
Thanks again everyone
This would involve use of the Schedulable apex interface.
I strongly recommend you check out the related Trailhead course: https://trailhead.salesforce.com/en/content/learn/modules/asynchronous_apex/async_apex_scheduled
trigger UpdateWhatever__c on Lead (before update) {
if(Lead.Whatever__c <> 1321){
Whatever__c = '42';
}
}
But am getting an error on line 1: Invalid character in identifier: UpdateWhatever__c
trigger UpdateWhatever on Lead (before update) {
if(Lead.Whatever__c <> 1321){
Whatever__c = '42';
}
}
on line 2 and 3saying varriable does not exist Whatever__c
I also removed the quotes around 42, assuming that Whatever__c is a numeric field. If it is a text field, you will want to put quotes around both 42 AND 1321.
I copied and pasted and don't even see a line 0
Please paste your full code as well as the full class or trigger name.
Now I just need to be able to schedule this for a nightly run. Any suggestions?
Thanks again, I'm still learning
Use the Trailhead link that Aubry posted earlier to learn about creating a schedulable job. And, if possible remove the Process Builder you wrote and place it's actions into the schedulable class as you don't want or need two things stepping on each other.