Activity Forums Salesforce® Discussions How to update a field after every 24hrs in salesforce?

  • Kumar

    Member
    January 9, 2017 at 5:33 am

    Hi Pranav,

    You can use schedulable apex to auto-update a field every 24hrs.

    Following is the snippet of anonymous code which will help you to schedule your apex Job to run Every HOUR.

    ScheduleclassEveryhour objschclass = new ScheduleclassEveryhour ();
    string strSeconds = '0';
    string strMinutes = '0';
    string strHours = '0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23';
    string strDay_of_month = '*';
    string strMonth = '*';
    string strDay_of_week = '?';
    String sch = strSeconds + ' ' + strMinutes + ' ' + strHours + ' ' + strDay_of_month + ' ' + strMonth + ' ' + strDay_of_week;
    system.schedule('ScheduleclassEveryhour', sch, objschclass);

    You can implement the field updation logic inside this 'ScheduleclassEveryhour' class which implements the Schedulable interface.

    Hope this helps!

     

     

     

    • This reply was modified 7 years, 11 months ago by  Kumar.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos