zoukankan      html  css  js  c++  java
  • 在Salesforce中创建Schedule的Job去定时触发对应的Class

    在Salesforce中也存在着Job的概念,当然了我们可以创建Schedule的Job去定时触发对应的Class,来完成我们所需要定时处理的功能,比如:定时同步数据。

    具体处理步骤如下所示:

    1):创建的Class需要继承Schedulable接口,并且实现对应的execute方法,在execute的方法中可以完成我们自己的代码逻辑

    global class SyncStoreController implements Schedulable {
        //call the web service to get the store info
        global void execute(SchedulableContext SC) {
          system.debug('---------001 HaHaHa. I am sync store controller.');
          
          // to do - complete your logic
       }
    }

    2):到Salesforce中的Apex Classes中找到Schedule Apex按钮

    3):点击上图中的Schedule Apex按钮,在显示的界面中填写必要的信息

      【Job Name以及Apex Class,点击搜索框,可以将有权限访问的并且继承了Schedulable接口的Class都Filter出来】

    4):设置Schedule Apex Execution,可以看到在界面上所设置的最小的执行单位是天,如果需要设置更小的执行单位,那么需要写执行代码去处理

      【详情请看:https://developer.salesforce.com/forums/ForumsMain?id=906F00000008xTBIAY 和 http://www.linkedin.com/groups/How-schedule-batch-class-after-3774731.S.88387420 】

    5):在如下路径中去查看Schedule的Jobs 【Setup --> Jobs --> Scheduled Jobs】

    6):在如下路径中去查看Apex的Jobs【Setup --> Jobs --> Apex Jobs】

     若要在Schedule Job中去call web service,那么需要在对应的function上添加@future(callout=true)这样的标识。

     要不然会提示这样的错误:System.CalloutException: Callout from scheduled Apex not supported.

     更多详细信息请看如下链接: http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_scheduler.htm 

  • 相关阅读:
    2019-1-25-win10-uwp-禁用-ScrollViewer-交互
    2019-1-25-win10-uwp-禁用-ScrollViewer-交互
    2018-8-13-WPF-使用-Edge-浏览器
    2018-8-13-WPF-使用-Edge-浏览器
    2018-10-23-使用-Pandoc-把-Markdown-转-Docx
    2018-10-23-使用-Pandoc-把-Markdown-转-Docx
    Java实现 LeetCode 486 预测赢家
    PDO::getAttribute
    PDO::beginTransaction
    PDO::exec
  • 原文地址:https://www.cnblogs.com/mingmingruyuedlut/p/3593140.html
Copyright © 2011-2022 走看看