Home > Forum > Rules, JS, SQL > Starting SQL Subworkflow using Item List

Starting SQL Subworkflow using Item List
0

Hello,

I'm trying to start a subworkflow from an item list. My item list will have the candidate for Positions and it will not be filled at the same time, each time there's a candidate for an offer, the user creates a row.
To start my subworkflow I'm using as conditions having the candidate name as not null and a flag set to true and i'm using this as an execution condition with the following SQL:

if exists (
select 1 from WFElementDetails
where DET_WFDID={WFD_ID} and DET_WFCONID={WFCON:1726}
and isnull({DCNCOL:119}, '') <> ''
and {DCNCOL:118} = 'Yes'
)
select 1 else
select 0

But it doesn't trigger my subworkflow.

Does anyone have a similar case that could help?

Thank you!

MVP

Hi Andreia,

I'm guessing that this line contains the boolean column.
and {DCNCOL:118} = 'Yes'

and doesn't return a row. Did you write Yes or is this an internal variable which gets replaced in the expression editor?

Nevertheless you could test with this:
isnull({DCNCOL:118}, 0) = 0
Even boolean columns can contain NULL values. If you didn't explicitly set it to 0 (False/No) it won't have a value.

You could easily see what values are stored if you only execute/test something like this
select isnull({DCNCOL:119}, '') as A,
{DCNCOL:118} as B
from WFElementDetails
where DET_WFDID={WFD_ID} and DET_WFCONID={WFCON:1726}


What I'm not sure about is, that you are posting here the execution condition. So does your action work without the execution condition and it's simply not triggered. Or does your action not work regardless of the execution condition.

Regardless of this I have one hint. Instead of saving a boolean value if a sub workflow has been started for the row, store the workflow id which was started. With this you could add a field which rendered a link so that the user can easily navigate to the sub workflow.


Best regards,
Daniel

In reply to: Daniel Krüger (Cosmo Consult)

Hi Andreia,

I'm guessing that this line contains the boolean column.
and {DCNCOL:118} = 'Yes'

and doesn't return a row. Did you write Yes or is this an internal variable which gets replaced in the expression editor?

Nevertheless you could test with this:
isnull({DCNCOL:118}, 0) = 0
Even boolean columns can contain NULL values. If you didn't explicitly set it to 0 (False/No) it won't have a value.

You could easily see what values are stored if you only execute/test something like this
select isnull({DCNCOL:119}, '') as A,
{DCNCOL:118} as B
from WFElementDetails
where DET_WFDID={WFD_ID} and DET_WFCONID={WFCON:1726}


What I'm not sure about is, that you are posting here the execution condition. So does your action work without the execution condition and it's simply not triggered. Or does your action not work regardless of the execution condition.

Regardless of this I have one hint. Instead of saving a boolean value if a sub workflow has been started for the row, store the workflow id which was started. With this you could add a field which rendered a link so that the user can easily navigate to the sub workflow.


Best regards,
Daniel

Hi! My execution condition is to trigger only on certain conditions. I made a change in the SQL command for my execution (see the picture) but I'm always launching subworkflows even for those already done so I came up with that idea of having the Instance ID of the subworkflow but how to manage to copy that inside the item list?

I created an action in the subworkflow to update the item list but I'm not able to add the Inst. Number for the line that created the subworkflow.
I'm saying that the Unique Value is the IstanceID Child (column) and I have the SQL query as:
select {WFD_ID} as {DCNCOL:121} (aka instanceID child)
from WFElements
where WFD_ID='{WFD_ID}'

MVP
In reply to: Andreia Correia

Hi! My execution condition is to trigger only on certain conditions. I made a change in the SQL command for my execution (see the picture) but I'm always launching subworkflows even for those already done so I came up with that idea of having the Instance ID of the subworkflow but how to manage to copy that inside the item list?

I created an action in the subworkflow to update the item list but I'm not able to add the Inst. Number for the line that created the subworkflow.
I'm saying that the Unique Value is the IstanceID Child (column) and I have the SQL query as:
select {WFD_ID} as {DCNCOL:121} (aka instanceID child)
from WFElements
where WFD_ID='{WFD_ID}'

Hi Andreia,

whenever I'm creating sub workflows from an item list I have two actions:
1. Creating the sub workflows
2. Updating the item list

1. While creating the sub workflow a unique value get's passed to the sub workflow. If this shouldn't be visible I use a technical field.

2. Then I update the item list

select
DET_ID -- unique id of the row which is used for updating the row,
'Ongoing' as DET_Att3 -- some other attribute,

-- get the sub workflow Id
(
select WFD_ID from WFElements
where
-- Matching all sub workflow of the current one
WFD_WFDID = 9036 and -- use Instance Id instead of 9036
-- and use a field which maps the specific sub workflow to the the row.
-- In my case I stored the DET_ID of the row by which the workflow was created.
DET_ID = WFD_AttInt1
)
as DET_Value1 -- write sub workflow Id to your item list field

from WFElementDetails

where DET_WFDID = 9036 -- Instance Id

Best regards,
Daniel

In reply to: Daniel Krüger (Cosmo Consult)

Hi Andreia,

whenever I'm creating sub workflows from an item list I have two actions:
1. Creating the sub workflows
2. Updating the item list

1. While creating the sub workflow a unique value get's passed to the sub workflow. If this shouldn't be visible I use a technical field.

2. Then I update the item list

select
DET_ID -- unique id of the row which is used for updating the row,
'Ongoing' as DET_Att3 -- some other attribute,

-- get the sub workflow Id
(
select WFD_ID from WFElements
where
-- Matching all sub workflow of the current one
WFD_WFDID = 9036 and -- use Instance Id instead of 9036
-- and use a field which maps the specific sub workflow to the the row.
-- In my case I stored the DET_ID of the row by which the workflow was created.
DET_ID = WFD_AttInt1
)
as DET_Value1 -- write sub workflow Id to your item list field

from WFElementDetails

where DET_WFDID = 9036 -- Instance Id

Best regards,
Daniel

Hi Daniel!

By doing your method, my column is getting updated with the Parent ID rather than the child. Not sure if I'm doing some wrong here:

select
DET_Att5 as Candidate, (the candidate name is passing on the subworkflow)
(
select {WFD_ID} from WFElements (using instance ID)
where
WFD_WFDID = {WFCONCOL:1773} and --- I'm already passing the Parent ID for the subworkflow, so I set the Instance ID from Parent = my technical field with the ID from the Parent

{DCNCOL:119} = {WFCONCOL:1649} (candidate name equal in both)
)
as DET_Att1 (Parent ID column in item list)
from WFElementDetails
where DET_WFDID = {WFD_ID}