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

查看:200
本文介绍了在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分钟运行一次.我从监控">调试日志"中看到调试日志,它没有显示日志.您能告诉我每分钟运行一次作业的表达式是什么,以及在哪里可以看到调试日志吗?我的目的是看到可安排的工作

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天全站免登陆