Hi,

I'd like to set a the timer of a task at runtime. This means I have to populate a net variable of type YTimerType at runtime.

Let's say I have a task "setTimer" that would do exactly this. It would have a String variable "Duration" which would either have the value "long" or "short".
In this task under Output mapping my approach was to populate the net variable "timer" (of said type YTimerType) like so:

<timer>
if ({/setTimer/duration/text()} = long) then
PT30S
else
if({/setTimer/duration/text()} = short) then
PT20S
else
PT5s
</timer>

By this I try to active that if "duration" is "long", "timer" is 30 seconds, if "duration" is "short", "timer" is 20 seconds. If "duration" is anything else, "timer" is 5s.

Obviously, this fails miserably. I guess this is because of my xquery skills ... can you fix this?

ps: Attached you find a minimal example, much like what I wrote in the text.

example.yawl (11.54 KB)

mRoskosch

Thu, 05/24/2012 - 12:12

I have tried the following query and it returned the values you specified:

{if(/setTimer/duration/text()='long')then'PT30S'else(if(/setTimer/duration/text()='short')then'PT20S'else'PT5S')}

Where "setTimer" is the name of the net and "duration" the name of the variable containing either "long", "short" or something else.

You need to add the curly brackets, if you want do anything besides enter characters as values.

When using the if clause, then the values need to be surrounded by single quotation marks " ' ". Any further if clauses inside the if clause need to be surrounded by parentheses. Xpath expressions for variable values don't need any more brackets, if the expression is already in curvy brackets.

Hope this helps.

Regards,

Markus

 

Stefan Albracht

Thu, 05/24/2012 - 13:14

Hi,

thanks for you quick reply. I implemented this into my workflow (see attached file, this is not the minimal example anymore, so I guess it's rather useless to you).
Once the output mapping is executed I get the following error message in the UI:

BAD PROCESS DEFINITION. Data extraction failed schema validation at task completion. Task [Incident_priorisieren_und_erste_Diagonse_37] Validation error message [Error: 2:23: cvc-complex-type.2.3: Element 'timer' cannot have character [children], because the type's content type is element-only. Error: 2:23: cvc-complex-type.2.4.b: The content of element 'timer' is not complete. One of '{trigger}' is expected. ]

I don't understand that. What does this mean. Does this mean that 'PT10S' is not a valid value for YTimerTime?

Cheers,
Stefan

mRoskosch

Thu, 05/24/2012 - 18:01

The YTimerType is a special data type that consits of two values (see manual2.2 p.104). If you create a net variable and put in an initial value, the error will tell you how to build this data type. A valid value is for example this:

<trigger>OnEnabled</trigger>
<expiry>PT5S</expiry>

Therefore we need to chage the query a bit like this:


  <trigger>OnEnabled</trigger>
  <expiry>{if(/IncidentManagement/Prioritaet/text()='niedrig')then'PT30S'else(if(/IncidentManagement/Prioritaet/text()='mittel')then'PT20S'else'PT10S')}</expiry>

You might still get problems for using a net variable in the output mapping, because you should better use a task variable.

I have tested the workflow with this mapping and after the task expired, there were no work-items left for the case, but the case was still there.

Regards,

Markus

Stefan Albracht

Thu, 05/24/2012 - 21:09

Wow, complicated. I would not have found this out without you, thanks. I guess it makes sense in the YAWL-Kind of way. However, I do not understand why there are no work items left when the timer runs out. Do you have any thoughts on that?

I will get into that on Monday. Maybe will even open another topic :)

Best,
Stefan