What is the project scope of onSchedule rules?

I have a workflow with many modules. One module is an onSchedule. The workflow is attached to many projects.

Is there a way in the Workflow API to determine this project that the workflow is currently executing in?

Alternatively, if only one instance of the onSchedule workflow runs for all attached projects, is there a way in the API to see which projects have this workflow attached? I'd like to change some fields on a schedule, but only for projects with this workflow attached.


1 comment
Comment actions Permalink
Official comment

Hi David,

It usually helps to keep in mind that workflows are always issue-centric. Each rule execution happens in the context of some issue. So, as a rule of thumb, one only invokes workflows for relevant issues, making additional filtering unnecessary.

You can, of course, always check ctx.issue.project value to find out the specific project the rule is running against.

I hope it helps.

exports.rule = entities.Issue.onSchedule({
  title: 'Notify assignee about overdue issues',
  search: '#Unresolved has: {Due Date}',   // <- select only what's relevant
  cron: '0 0 10 ? * MON-FRI',
  guard: (ctx) => {                        // <- more complex filering conditions may be added here
    return ctx.issue.fields.DueDate < Date.now();
  action: (ctx) => {
// it's guaranteed that ctx.issue matches the criteria defined above

Please sign in to leave a comment.