Workflow Condition on Catalog Task

koxon
Kilo Explorer

Hi,

I would like to have a condition in my task based on the close state of the task.
If the task is close complete I would like to continue the workflow normally, however, if the state is "close incomplete" or "close skipped" I want to end the workflow.

I added two conditions to my task:
- If Close complete -> continue normally
- Else -> End the workflow

I tried many syntax to match the state field of the task (task.state == 3 ; State == 3 ... etc) ... without success. As this is not documented (again), I don't want to waist my time and I ask here for help.

Could you please tell me how I can have a condition on the closing state of my task ?

Thanks

7 REPLIES 7

Jace Benson
Mega Sage

I'm going to assume this workflow is on the sc_req_item table and not the sc_task table. If that's the case, which it normally is for catalog item workflows the problem I think you are having is the condition (are you using an if condition activity?) is checking against the current ritm and not the previous task.


Hi,

You are right this is a workflow on the sc_req_item table.
I am trying to have a condition on the task iteself. In fact the if condition cannot access the information of the previous task.
On the catalog task I can create conditions, which I did. I just don't know how to test against the State field of the task.

Any idea ?

Thanks


If this is something you want to do for all tasks then you could put a Business Rule on the Catalog Task table that checks for the closure state and then goes up to the Request Item and cancels it from there.

I did a quick test and found this to work:



gs.addInfoMessage("Starting Test: state=" + current.state);
if(current.state == "4"){
gs.addInfoMessage("Cancel script goes here");
}


If this is just a one time thing that is specific to a workflow or two then you might be able to create a hidden variable and store the state of the task that you want to test for in there and then check against that later.


Hi,

Thanks but my admin didn't give us access to the business rules. We need to specificaly request a business rule and they will implement it for us.
I was just wondering what is the use of the conditions inside the task then ? In the workflow a task can have many conditions, what is the use of those and what is the scope ? I thought this could be used to condition the close state of the task ... the default condition being "always" that sounds logical.

If you look at this example:
http://wiki.service-now.com/index.php?title=File:SCWorkflow2.png

There is a task with two condition:
- Backordered
- In Stock

Could you explain the way to use that and if I could use it to test against my Task state. That would be logical that I could use this feature to do what I need. But this is not documented ... or I couldn't find it.

Thanks