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
vanessa veronvanessa veron 

Trigger Update Custom Object

Hi...
I have a custom object that I would like to change the value of field PREVIOUS_FIRE this my object, when the PreviousFireTime of CronTrigger value be changed.
How do I update the field from my custom object based on field CronTrigger?

Thank you
Cloud_forceCloud_force
you can use trigger.old to get old values of the field and compare with new values in trigger.new 

thanks,http://www.forcexplore.com/2014/07/wrapper-class-in-salesforce.html

vanessa veronvanessa veron
The link has nothing about OLD and NEW.
vanessa veronvanessa veron
Give me an example please.

Thank you
vanessa veronvanessa veron
Thank you...
But I do not know which will be performed the action .
I change that has changed the date of the last execution.
ShashForceShashForce
Hi,

Unfortunately, we cannot write a trigger on the CronTrigger object.

One workaround which you can probably try out is to:
1.) Create a Custom Setting object (http://help.salesforce.com/HTViewHelpDoc?id=cs_about.htm&language=en_US) and save the crontrigger object field values in it.
2.) Create a scheduled Apex class to check if the PreviousFireTime has changed from the value stored in custom setting record and update the custom object field if so.

Just a thought!

If this answers your question, please mark this as the Best Answer for this post, so that others can benefit from this post.

Thanks,
Shashank
vanessa veronvanessa veron
Isn't it possible

anything like:

trigger Compare_OldandNewvalues on CronTrigger (after update) {

   for (CronTrigger cy: Trigger.new) {
        CronTrigger oldCt = Trigger.oldMap.get(ct.ID);
        if(ct.PreviousFireTime != oldCt.PreviousFireTime) {
           System.debug('--*Account Number is changed*--');  
        }
        else{
            System.debug('--**Account Number has not been Updated**--');
        }
    }
}
?
vanessa veronvanessa veron
Hello,

has the possibility within the same table I use the value of field custom object and the value of field CronTrigger?

That would solve my problem.

<apex:pageBlockTable value="{!tableTitre }" var="title"><apex:column headervalue=xxxxxxxxxxxx"/></apex:pageBlockTable>
          
          <apex:pageBlockTable value="{!jobRecords2}" var="ac" id="pbBlockTable">
                <apex:column headervalue="Nom" value="{!ac.nomJobCS__c}"/>
                <apex:column headervalue="Date Creation" value="{!ac.jobDtCreation__c}"/>
                <apex:column headervalue="Status" value="{!ac.jobStatus__c}"/>
                <apex:column headervalue="Last Execution" value="{!ac.jobDtDerniereExec__c}"/>
                <apex:column headervalue="Next  Execution" value="{!ac.jobDtProchaineExec__c}"/>
                
          <apex:pageBlockTable value="{!jobRecords}" var="ct" id="pbBlockTable">      
                <apex:column headervalue="Last Execution2" value="{!ct.PreviousFireTime}"/>
                <apex:column headervalue="Next Execution2" value="{!ct.NextFireTime}"/>
          </apex:pageBlockTable>
                                  
              </apex:pageBlockTable>