在 apex salesforce 中调试可调度作业 [英] Debugging Schedulable Job in apex salesforce

查看:41
本文介绍了在 apex salesforce 中调试可调度作业的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行一个可安排的工作,我从未在 Salesforce 中使用过可安排的工作

i am trying to run a schedulable job i never used schedulable jobs in salesforce

这是我的代码

global class scheduledMerge implements Schedulable{
   global void execute(SchedulableContext SC) {
      System.debug('Hello World'); 
   }
}

          created a cusom controller
public class schedulableMerge{

public schedulableMerge(){

}
public PageReference Hello(){
scheduledMerge m = new scheduledMerge();
        String sch = '0 10 * * 1-12 ? *';
        system.schedule('Merge Job', sch, m);
        return null;
}

}

和visualforce页面是

and visualforce page is

<apex:page controller="schedulableMerge">
  <!-- Begin Default Content REMOVE THIS -->
    <h1>Congratulations</h1>
  This is your new Page
  <!-- End Default Content REMOVE THIS -->
  <apex:form >
  <apex:commandButton value="Press it" action="{! Hello}" />
</apex:form>

</apex:page>

当我按下按钮时,所有可调度作业中有一个作业,但只有一个选项可以删除.没有管理选项.我认为这项工作应该每 10 分钟运行一次.我从 Monitoring>Debug Log 看到调试日志,它没有显示日志.你能告诉我每分钟运行一次作业的表达式是什么,在哪里可以看到调试日志??我的目标是查看可安排工作的工作

when i press button press it there is a job in All schedulable job but there is only one option delete with it.No option of manage. i think this job should run in every 10 minutes .i saw debug logs from Monitoring>Debug Log it is showing no log. can you please tell what is the expression for running job in every one minute and where to see debug logs?? my aim is to see working of schedulable job

推荐答案

好消息 - 您不需要 Visualforce 页面和控制器.坏消息 - 您不能以 1 分钟的间隔安排作业.我认为 5 分钟是最短时间(但我不确定,您必须尝试一下).

Good news - you don't need a visualforce page and controller. Bad news - you can't schedule jobs with 1 minute intervals. I think 5 mins is the minimum (but I'm not sure, you'd have to experiment with it).

如何按需运行(一次)?从开发者控制台或 Eclipse 的执行匿名"块.

How to run it (once) on demand? From Developer Console or Eclipse's "Execute Anonymous" block.

确保您的用户已添加到调试日志中,并只需强制运行您必须作为接口的一部分实现的 execute 方法:

Make sure your user is added to debug logs and simply force running of the execute method you had to implement as part of the interface:

scheduledMerge sm = new scheduledMerge();
sm.execute(null);

在您对一次运行成功完成感到满意后,使用 cron 表达式进行实验.如果您对频率每天一次没问题 - 您根本不需要这些表达式,请转到设置 -> 开发 -> 类并单击 [Schedule Apex].仅当您一天需要多次运行时,才使用代码来安排课程.

Experiment with the cron expressions after you're satisfied that one run completes succesfully. If you're fine with frequency once a day - you don't need these expressions at all, go to Setup -> Develop -> Classes and click [Schedule Apex]. Only if you need multiple runs a day use code to schedule the class.

最后但并非最不重要的 - 转到设置并在搜索中输入Apex 工作".您应该看到最近执行的所有异步任务的信息(计划作业、批处理、@future 方法等)

Last but not least - go to setup and type "Apex jobs" in the search. You should see info of all asynchronous tasks performed recently (scheduled jobs, batches, @future methods etc)

这篇关于在 apex salesforce 中调试可调度作业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆