# Can timeCycle be made dynamic\<startEvent id="startEvent"\> \<timerEventDefinition\> \<timeCycle\>${expression}\</timeCycle\> \</timerEventDefinition\> \</startEvent\>

**URL:** <https://forum.flowable.org/t/can-timecycle-be-made-dynamic-startevent-id-startevent-timereventdefinition-timecycle-expression-timecycle-timereventdefinition-startevent/669>\
**Category:** Uncategorized\
**Created:** [June 22, 2017, 9:31am UTC](https://forum.flowable.org/t/can-timecycle-be-made-dynamic-startevent-id-startevent-timereventdefinition-timecycle-expression-timecycle-timereventdefinition-startevent/669 "2017-06-22T09:31:40Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![vibhu08](https://avatars.discourse-cdn.com/v4/letter/v/ac8455/32.png) [@vibhu08](https://forum.flowable.org/u/vibhu08)\
**Post date:** [June 22, 2017, 9:31am UTC](https://forum.flowable.org/t/can-timecycle-be-made-dynamic-startevent-id-startevent-timereventdefinition-timecycle-expression-timecycle-timereventdefinition-startevent/669/1 "2017-06-22T09:31:40Z")

</div>

However getting error-  
Exception in thread “main” org.flowable.engine.common.api.FlowableException: Unknown property used in expression: ${expression}  
at org.flowable.engine.impl.el.JuelExpression.getValue(JuelExpression.java:60)  
at org.flowable.engine.impl.util.TimerUtil.createTimerEntityForTimerEventDefinition(TimerUtil.java:98)  
at org.flowable.engine.impl.asyncexecutor.DefaultJobManager.createTimerJob(DefaultJobManager.java:108)  
at org.flowable.engine.impl.bpmn.deployer.TimerManager.getTimerDeclarations(TimerManager.java:75)  
at org.flowable.engine.impl.bpmn.deployer.TimerManager.scheduleTimers(TimerManager.java:58)  
at org.flowable.engine.impl.bpmn.deployer.BpmnDeploymentHelper.updateTimersAndEvents(BpmnDeploymentHelper.java:153)  
at org.flowable.engine.impl.bpmn.deployer.BpmnDeployer.updateTimersAndEvents(BpmnDeployer.java:212)  
at org.flowable.engine.impl.bpmn.deployer.BpmnDeployer.deploy(BpmnDeployer.java:87)  
at org.flowable.engine.impl.persistence.deploy.DeploymentManager.deploy(DeploymentManager.java:60)  
at org.flowable.engine.impl.cmd.DeployCmd.executeDeploy(DeployCmd.java:116)  
at org.flowable.engine.impl.cmd.DeployCmd.execute(DeployCmd.java:66)  
at org.flowable.engine.impl.cmd.DeployCmd.execute(DeployCmd.java:40)  
at org.flowable.engine.impl.interceptor.CommandInvoker$1.run(CommandInvoker.java:44)  
at org.flowable.engine.impl.interceptor.CommandInvoker.executeOperation(CommandInvoker.java:86)  
at org.flowable.engine.impl.interceptor.CommandInvoker.executeOperations(CommandInvoker.java:65)  
at org.flowable.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:49)  
at org.flowable.engine.impl.interceptor.TransactionContextInterceptor.execute(TransactionContextInterceptor.java:51)  
at org.flowable.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:64)  
at org.flowable.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:36)  
at org.flowable.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:56)  
at org.flowable.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:51)  
at org.flowable.engine.impl.RepositoryServiceImpl.deploy(RepositoryServiceImpl.java:93)  
at org.flowable.engine.impl.repository.DeploymentBuilderImpl.deploy(DeploymentBuilderImpl.java:188)  
at SchedulingTest.SchedulingClassTest.main(SchedulingClassTest.java:28)  
Caused by: javax.el.PropertyNotFoundException: Cannot resolve identifier 'expression’  
at de.odysseus.el.tree.impl.ast.AstIdentifier.eval(AstIdentifier.java:93)  
at de.odysseus.el.tree.impl.ast.AstEval.eval(AstEval.java:51)  
at de.odysseus.el.tree.impl.ast.AstNode.getValue(AstNode.java:31)  
at de.odysseus.el.TreeValueExpression.getValue(TreeValueExpression.java:122)  
at org.flowable.engine.impl.delegate.invocation.ExpressionGetInvocation.invoke(ExpressionGetInvocation.java:33)  
at org.flowable.engine.impl.delegate.invocation.DelegateInvocation.proceed(DelegateInvocation.java:35)  
at org.flowable.engine.impl.delegate.invocation.DefaultDelegateInterceptor.handleInvocation(DefaultDelegateInterceptor.java:25)  
at org.flowable.engine.impl.el.JuelExpression.getValue(JuelExpression.java:56)  
… 23 more

---

<div class="post-metadata">

**Author:** ![joram](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/joram/32/26_2.png) [@joram](https://forum.flowable.org/u/joram)\
**Post date:** [June 22, 2017, 3:52pm UTC](https://forum.flowable.org/t/can-timecycle-be-made-dynamic-startevent-id-startevent-timereventdefinition-timecycle-expression-timecycle-timereventdefinition-startevent/669/2 "2017-06-22T15:52:20Z")

</div>

Can you paste the snipper of your bpmn 2.0 xml?

Have you properly set the expression variable?

---

<div class="post-metadata">

**Author:** ![vibhu08](https://avatars.discourse-cdn.com/v4/letter/v/ac8455/32.png) [@vibhu08](https://forum.flowable.org/u/vibhu08)\
**Post date:** [June 23, 2017, 6:48am UTC](https://forum.flowable.org/t/can-timecycle-be-made-dynamic-startevent-id-startevent-timereventdefinition-timecycle-expression-timecycle-timereventdefinition-startevent/669/3 "2017-06-23T06:48:20Z")

</div>

\<?xml version="1.0" encoding="UTF-8"?\>

```
<startEvent id="startEvent">
<timerEventDefinition>
            <timeCycle>${expression}</timeCycle>
          
        </timerEventDefinition>
        </startEvent>    

<sequenceFlow sourceRef="startEvent" targetRef="workEvent"/>

```

```
        </serviceTask>

```

```
<endEvent id="endEvent"/>

```

---

<div class="post-metadata">

**Author:** ![joram](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/joram/32/26_2.png) [@joram](https://forum.flowable.org/u/joram)\
**Post date:** [June 23, 2017, 7:09am UTC](https://forum.flowable.org/t/can-timecycle-be-made-dynamic-startevent-id-startevent-timereventdefinition-timecycle-expression-timecycle-timereventdefinition-startevent/669/4 "2017-06-23T07:09:53Z")

</div>

That looks allright. Where do you set the expression variable?

---

<div class="post-metadata">

**Author:** ![vibhu08](https://avatars.discourse-cdn.com/v4/letter/v/ac8455/32.png) [@vibhu08](https://forum.flowable.org/u/vibhu08)\
**Post date:** [June 23, 2017, 7:11am UTC](https://forum.flowable.org/t/can-timecycle-be-made-dynamic-startevent-id-startevent-timereventdefinition-timecycle-expression-timecycle-timereventdefinition-startevent/669/5 "2017-06-23T07:11:55Z")

</div>

public class SchedulingClassTest {  
public static void main(String[] args) throws InterruptedException {  
ProcessEngineConfiguration cfg = new StandaloneProcessEngineConfiguration()  
.setJdbcUrl(“jdbc:h2:mem:flowable;DB\_CLOSE\_DELAY=-1”)  
.setAsyncExecutorActivate(true)  
.setJdbcUsername(“sa”)  
.setJdbcPassword("")  
.setJdbcDriver(“org.h2.Driver”)  
.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB\_SCHEMA\_UPDATE\_TRUE);//Process Engine Configuration  
ProcessEngine processEngine = cfg.buildProcessEngine(); //Building Process Engine  
RepositoryService repositoryService = processEngine.getRepositoryService();  
org.flowable.engine.repository.Deployment deployment = repositoryService.createDeployment()  
.addClasspathResource(“request.bpmn20.xml”)  
.deploy(); //Deploying Process Definition  
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()  
.deploymentId(deployment.getId())  
.singleResult();  
String expression = “0 0 \* ? \* \*”;  
System.out.println("Found process definition : " + processDefinition.getName());//Printing name of Process Definition  
Scanner scanner= new Scanner([System.in](http://System.in));  
System.out.println(“Enter?”);  
expression = scanner.nextLine();  
RuntimeService runtimeService = processEngine.getRuntimeService();  
runtimeService.setVariable(“startEvent”,“expression”,expression);

```
  }

```

}

---

<div class="post-metadata">

**Author:** ![joram](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/joram/32/26_2.png) [@joram](https://forum.flowable.org/u/joram)\
**Post date:** [June 23, 2017, 3:01pm UTC](https://forum.flowable.org/t/can-timecycle-be-made-dynamic-startevent-id-startevent-timereventdefinition-timecycle-expression-timecycle-timereventdefinition-startevent/669/6 "2017-06-23T15:01:42Z")

</div>

> [@vibhu08](#):
>
> runtimeService.setVariable(“startEvent”,“expression”,expression);

What’s the “startEvent” parameter? That needs to be an executionId of the process instance.

---

<div class="post-metadata">

**Author:** ![Vibhu\_Kumar](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/vibhu_kumar/32/219_2.png) [@Vibhu\_Kumar](https://forum.flowable.org/u/Vibhu_Kumar)\
**Post date:** [June 23, 2017, 6:34pm UTC](https://forum.flowable.org/t/can-timecycle-be-made-dynamic-startevent-id-startevent-timereventdefinition-timecycle-expression-timecycle-timereventdefinition-startevent/669/7 "2017-06-23T18:34:19Z")

</div>

Is exectionId = id we used for process definition

---

<div class="post-metadata">

**Author:** ![Vibhu\_Kumar](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/vibhu_kumar/32/219_2.png) [@Vibhu\_Kumar](https://forum.flowable.org/u/Vibhu_Kumar)\
**Post date:** [June 23, 2017, 6:34pm UTC](https://forum.flowable.org/t/can-timecycle-be-made-dynamic-startevent-id-startevent-timereventdefinition-timecycle-expression-timecycle-timereventdefinition-startevent/669/8 "2017-06-23T18:34:56Z")

</div>

![](https://cdck-file-uploads-canada1.s3.dualstack.ca-central-1.amazonaws.com/flex035/uploads/flowable/original/1X/1d0dc750d1c27a189a26316d07f842a2f145b192.png)

---

<div class="post-metadata">

**Author:** ![Vibhu\_Kumar](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/vibhu_kumar/32/219_2.png) [@Vibhu\_Kumar](https://forum.flowable.org/u/Vibhu_Kumar)\
**Post date:** [June 23, 2017, 6:38pm UTC](https://forum.flowable.org/t/can-timecycle-be-made-dynamic-startevent-id-startevent-timereventdefinition-timecycle-expression-timecycle-timereventdefinition-startevent/669/9 "2017-06-23T18:38:24Z")

</div>

i have changed the line to runtimeService.setVariable(“workRequest”, “expression”,expression);  
But error still comming

---

<div class="post-metadata">

**Author:** ![joram](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/joram/32/26_2.png) [@joram](https://forum.flowable.org/u/joram)\
**Post date:** [June 26, 2017, 2:32pm UTC](https://forum.flowable.org/t/can-timecycle-be-made-dynamic-startevent-id-startevent-timereventdefinition-timecycle-expression-timecycle-timereventdefinition-startevent/669/10 "2017-06-26T14:32:43Z")

</div>

As the ‘expression’ is used for a start event, the ‘expression’ variable needs to be available right when the process instance is started. So you need to pass it when invoking runtimeService.startProcessInstanceByKey(“processKey”, variables);, where ‘variables’ is a Map containing the expression key/value.

---

<div class="post-metadata">

**Author:** ![vibhu08](https://avatars.discourse-cdn.com/v4/letter/v/ac8455/32.png) [@vibhu08](https://forum.flowable.org/u/vibhu08)\
**Post date:** [June 27, 2017, 3:56am UTC](https://forum.flowable.org/t/can-timecycle-be-made-dynamic-startevent-id-startevent-timereventdefinition-timecycle-expression-timecycle-timereventdefinition-startevent/669/11 "2017-06-27T03:56:18Z")

</div>

i tried this-  
runtimeService.startProcessInstanceById(“workRequest”, variables);   
but still getting same error.  
And I dont want to use runtimeService.startProcessInstanceById(“workRequest”, variables); because i am using timeCycle so the process should start itself at the particular time specified by cron expression.

---

<div class="post-metadata">

**Author:** ![vibhu08](https://avatars.discourse-cdn.com/v4/letter/v/ac8455/32.png) [@vibhu08](https://forum.flowable.org/u/vibhu08)\
**Post date:** [June 27, 2017, 4:15am UTC](https://forum.flowable.org/t/can-timecycle-be-made-dynamic-startevent-id-startevent-timereventdefinition-timecycle-expression-timecycle-timereventdefinition-startevent/669/12 "2017-06-27T04:15:18Z")

</div>

Hower if I remove the $ sign from expression in xml then i get error-  
Exception in thread “main” org.flowable.engine.common.api.FlowableException: Failed to parse cron expression: expression  
at org.flowable.engine.impl.calendar.CycleBusinessCalendar.resolveDuedate(CycleBusinessCalendar.java:38)  
at org.flowable.engine.impl.calendar.BusinessCalendarImpl.resolveDuedate(BusinessCalendarImpl.java:34)  
at org.flowable.engine.impl.util.TimerUtil.createTimerEntityForTimerEventDefinition(TimerUtil.java:115)  
at org.flowable.engine.impl.asyncexecutor.DefaultJobManager.createTimerJob(DefaultJobManager.java:108)  
at org.flowable.engine.impl.bpmn.deployer.TimerManager.getTimerDeclarations(TimerManager.java:75)  
at org.flowable.engine.impl.bpmn.deployer.TimerManager.scheduleTimers(TimerManager.java:58)  
at org.flowable.engine.impl.bpmn.deployer.BpmnDeploymentHelper.updateTimersAndEvents(BpmnDeploymentHelper.java:153)  
at org.flowable.engine.impl.bpmn.deployer.BpmnDeployer.updateTimersAndEvents(BpmnDeployer.java:212)  
at org.flowable.engine.impl.bpmn.deployer.BpmnDeployer.deploy(BpmnDeployer.java:87)  
at org.flowable.engine.impl.persistence.deploy.DeploymentManager.deploy(DeploymentManager.java:60)  
at org.flowable.engine.impl.cmd.DeployCmd.executeDeploy(DeployCmd.java:116)  
at org.flowable.engine.impl.cmd.DeployCmd.execute(DeployCmd.java:66)  
at org.flowable.engine.impl.cmd.DeployCmd.execute(DeployCmd.java:40)  
at org.flowable.engine.impl.interceptor.CommandInvoker$1.run(CommandInvoker.java:44)  
at org.flowable.engine.impl.interceptor.CommandInvoker.executeOperation(CommandInvoker.java:86)  
at org.flowable.engine.impl.interceptor.CommandInvoker.executeOperations(CommandInvoker.java:65)  
at org.flowable.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:49)  
at org.flowable.engine.impl.interceptor.TransactionContextInterceptor.execute(TransactionContextInterceptor.java:51)  
at org.flowable.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:64)  
at org.flowable.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:30)  
at org.flowable.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:56)  
at org.flowable.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:51)  
at org.flowable.engine.impl.RepositoryServiceImpl.deploy(RepositoryServiceImpl.java:93)  
at org.flowable.engine.impl.repository.DeploymentBuilderImpl.deploy(DeploymentBuilderImpl.java:188)  
at SchedulingTest.SchedulingClassTest.main(SchedulingClassTest.java:34)  
Caused by: java.text.ParseException: Illegal characters for this position: 'EXP’  
at org.flowable.engine.impl.calendar.CronExpression.storeExpressionVals(CronExpression.java:428)  
at org.flowable.engine.impl.calendar.CronExpression.buildExpression(CronExpression.java:334)  
at org.flowable.engine.impl.calendar.CronExpression.(CronExpression.java:252)  
at org.flowable.engine.impl.calendar.CycleBusinessCalendar.resolveDuedate(CycleBusinessCalendar.java:33)  
… 24 more

---

<div class="post-metadata">

**Author:** ![joram](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/joram/32/26_2.png) [@joram](https://forum.flowable.org/u/joram)\
**Post date:** [June 27, 2017, 1:41pm UTC](https://forum.flowable.org/t/can-timecycle-be-made-dynamic-startevent-id-startevent-timereventdefinition-timecycle-expression-timecycle-timereventdefinition-startevent/669/13 "2017-06-27T13:41:32Z")

</div>

> [@vibhu08](#):
>
> And I dont want to use runtimeService.startProcessInstanceById(“workRequest”, variables); because i am using timeCycle so the process should start itself at the particular time specified by cron expression.

Ok, I do see now.  
The problem is that you can’t pass a variable to it, as the instance will be started by the system.

In that case, you should use a pojo or Spring bean so you can do ${someBean.giveMeMyExpression()}.  
Note that you can reference any bean like that when you use Spring, but in other environments you need to pass the bean yourself: see [Open Source](http://www.flowable.org/docs/userguide/index.html#exposingConfigurationBeans)

---

<div class="post-metadata">

**Author:** ![Vibhu\_Kumar](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/vibhu_kumar/32/219_2.png) [@Vibhu\_Kumar](https://forum.flowable.org/u/Vibhu_Kumar)\
**Post date:** [June 27, 2017, 4:30pm UTC](https://forum.flowable.org/t/can-timecycle-be-made-dynamic-startevent-id-startevent-timereventdefinition-timecycle-expression-timecycle-timereventdefinition-startevent/669/14 "2017-06-27T16:30:54Z")

</div>

> [@joram](#):
>
> The problem is that you can’t pass a variable to it, as the instance will be started by the system.

But what is the problem with runtimeService.setVariable(“workRequest”, variable);  
And even if I am passing the variable in runtimeService.startProcessInstanceById(“workRequest”, variables); i am still getting same error

---

<div class="post-metadata">

**Author:** ![joram](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/joram/32/26_2.png) [@joram](https://forum.flowable.org/u/joram)\
**Post date:** [June 28, 2017, 11:54am UTC](https://forum.flowable.org/t/can-timecycle-be-made-dynamic-startevent-id-startevent-timereventdefinition-timecycle-expression-timecycle-timereventdefinition-startevent/669/15 "2017-06-28T11:54:28Z")

</div>

> [@Vibhu\_Kumar](#):
>
> But what is the problem with runtimeService.setVariable(“workRequest”, variable);

The problem is that you can only set variables on a running process instance. In this case, the instance hasn’t started yet (cause it will be started when the timer fires). I believe that “workRequest” is not your execution id, but your process definition id. Variables can only be set on process instances and executions.

---

<div class="post-metadata">

**Author:** ![vibhu08](https://avatars.discourse-cdn.com/v4/letter/v/ac8455/32.png) [@vibhu08](https://forum.flowable.org/u/vibhu08)\
**Post date:** [June 28, 2017, 11:55am UTC](https://forum.flowable.org/t/can-timecycle-be-made-dynamic-startevent-id-startevent-timereventdefinition-timecycle-expression-timecycle-timereventdefinition-startevent/669/16 "2017-06-28T11:55:40Z")

</div>

What is execution id ?  
 ![](https://cdck-file-uploads-canada1.s3.dualstack.ca-central-1.amazonaws.com/flex035/uploads/flowable/original/1X/1d0dc750d1c27a189a26316d07f842a2f145b192.png)

---

<div class="post-metadata">

**Author:** ![tijs](https://avatars.discourse-cdn.com/v4/letter/t/bc79bd/32.png) [@tijs](https://forum.flowable.org/u/tijs)\
**Post date:** [June 28, 2017, 12:13pm UTC](https://forum.flowable.org/t/can-timecycle-be-made-dynamic-startevent-id-startevent-timereventdefinition-timecycle-expression-timecycle-timereventdefinition-startevent/669/17 "2017-06-28T12:13:49Z")

</div>

Hi,

From reading all the previous posts, I think you should use a simple none start event and use an intermediate catch timer event after this start event. In this intermediate catch timer event you can use the expression like you describe and you can set the variable when starting the process instance.

Best regards,

Tijs

---

<div class="post-metadata">

**Author:** ![Vibhu\_Kumar](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/vibhu_kumar/32/219_2.png) [@Vibhu\_Kumar](https://forum.flowable.org/u/Vibhu_Kumar)\
**Post date:** [June 28, 2017, 5:10pm UTC](https://forum.flowable.org/t/can-timecycle-be-made-dynamic-startevent-id-startevent-timereventdefinition-timecycle-expression-timecycle-timereventdefinition-startevent/669/18 "2017-06-28T17:10:05Z")

</div>

But then the Intermediate catch timer wont work as time cycle.  
I tried using timecycle in intermediate catch event it only executes once and not as a timecycle.

---

<div class="post-metadata">

**Author:** ![tijs](https://avatars.discourse-cdn.com/v4/letter/t/bc79bd/32.png) [@tijs](https://forum.flowable.org/u/tijs)\
**Post date:** [June 29, 2017, 6:35am UTC](https://forum.flowable.org/t/can-timecycle-be-made-dynamic-startevent-id-startevent-timereventdefinition-timecycle-expression-timecycle-timereventdefinition-startevent/669/19 "2017-06-29T06:35:55Z")

</div>

Right, ok. That could be a feature request to add the time cycle capability to intermediate timer catch events as well. In the meantime there are 2 options I think. One is to loop back at the end of the process flow to the intermediate timer catch event, then you can use expressions. The other option is to use a (Spring) bean in your time cycle expression on a start event and let that bean calculate the time cycle value, instead of passing in a variable.

Best regards,

Tijs
