Accessing transient variable in service task

1
+1
-1

I need to send escalation for every task based on the timer condition. What I was looking at is to have a common Service task which sends email and use the same task to connect to a timer. Now just to know for which process I am sending escalation email, I tried defining a transient variable 'processName' at pool level with default value. And then I tried accessing its value directly by name for e.g. processName in the Service task connector. But this is not working and the engine says that variable is not defined.

Any idea how we can read value of transient value in a Service task connector?

Thanks, Dhananjay

Comments

Submitted by haris.subasic on Tue, 04/29/2014 - 12:03

There is a bit of misunderstanding. It is not possible to create a transient data on a pool level. It is possible to create a transient data on the service activity level, and you can then use it in the connectors that are linked to this activity. What can we do to help you?

Submitted by dhananjay.manohar on Tue, 04/29/2014 - 12:25

I tried at Pool level under Application->Transient Data, I thought it this variable is created at pool level (without getting stored in DB) and we can access it across all process. I also tried creating same at Task level, which has a boundary timer attached to it. There is a Service task to handle the timer expiration condition. And now I want to access this variable value in this service task. But either ways I am not able to access this variable directly using variable name. Any thoughts?

Thanks, Dhananjay

1 answer

1
0
-1

On a service task, you can create a data on General-Data tab, and select it as transient. It will be accessible in any connector on this task. Transient data that you find under Application-Transient data is reserved for the forms only. In your case, what you created under Application-Transient data on a pool level, will be used as a form data on the process initialization form.

Comments

Submitted by dhananjay.manohar on Tue, 04/29/2014 - 12:42

Ok then this doesn't solve my problem. I need to access this variable at a connector defined in boundary timer attached to the task. I think I will go back to a more of a data variable which I can use across all tasks.

Submitted by dhananjay.manohar on Wed, 04/30/2014 - 08:35

I want to basically avoid creating similar service task for every boundary timer associated to a human task. My ask is simple send a escalation at every task if boundary timer expires. I want one single service task to send escalation email. Since the escalation email is most of the times same, I just want to be able to pass the name of the task for which escalation email is being sent. I would have imagine to create a transient variable processName , whose value I can update for the current task I am running, and on expiration of timer, I can use this processName to send custom email specific to that task. Does that sound realistic or is there any limitation within Bonitasoft to achieve this?

Submitted by christine.mckinty on Wed, 04/30/2014 - 09:36

If you want a common escalation service task, you could put it in an event subprocess trigger by the boundary timer event. All the variables from the parent process are available in the event subprocess, so you don't need to map or pass any variables.

Submitted by haris.subasic on Wed, 04/30/2014 - 09:44

Just be careful, since using event subprocess would interrupt your main process. If this is not what you want to do, you can always create a simple subprocess with your service task that send the email. And then just use a call activity at different places and pass the service name as the variable to your subprocess. Would that help?

Submitted by dhananjay.manohar on Wed, 04/30/2014 - 10:17

Thanks Haris & Christine. I like the idea of creating a sub-process to send an email. But one thing I can't probably avoid is defining a call activity for every Human task having a boundary timer? My biggest pain point is I have to create 10 or so different call activities for every such task with different names for each of them and end up doing the same thing of calling a service task.

Submitted by christine.mckinty on Wed, 04/30/2014 - 12:12

Hmmm... I think you have to choose which is the bigger drawback: using an event subprocess is less work in creating the process definition, but in production your main process is interrupted; on the other hand, using call activities means no interruption of the main process but more work for you in creating the call activities. Which is more acceptable depends on the characteristics of your process. If you go with call activities, don't forget that you can copy/paste items in the diagram then change names later.

Submitted by dhananjay.manohar on Wed, 04/30/2014 - 13:12

Certainly I can do a copy paste of things and change their names, and I think eventually I would end up doing that. Is there a way I can pass constant as value such as the process name while mapping data between call activity and sub process?

Submitted by haris.subasic on Wed, 04/30/2014 - 13:27

You can have a transient data on a call activity that has a Groovy script for initial value and that takes process name, for example. And you can then map it to a variable of your subprocess.

Notifications