Home > Forum > General > How to check and assign task in subflow to users in item list column?

How to check and assign task in subflow to users in item list column?
0

I have Item list [slave]with column where I can pick people (from other item list [master] which contain 1. BPS users, 2. AD users (some of them are in BPS users - not all) and others - people out of AD and BPS.

1. I would like to run sub flow for each row of item list (done)
2. fill proper data (done)
3. assign to people from item list [slave] :
a) assign to all BPS users and skip non BPS users and others
b) if any of people is not BPS user then assign to person from form (who is BPS user)

What I did:
1. automation where I have
a) Set local variable "Manager" from form atribiute (user with BPS account)
2. For each item list row:
a) I thing about operator "Condition"
- how to do check condition ? to receive true or false
and then if:
false >> should be ease - assign subflow to "Manager"
true >> ship non BPS users and assign to bps user ...


[in "rectangle" is BPS user other are not ...]

You do not need to use "for each operator" .There is an action "run subflow" that you can use on the path. Use this action and pass all the information from subelements list. Action will start new flow for each row. After you pass all necassary info (people also possible but not neccessary) you will need to put an action "create task" on the path in the subflow. Assigning people is available by getting them from subflow form if you pass them, or you can use "sql command" to get them from master flow using wfd_id, det_wfdid, det_id columns from wfelements and wfelementdetails tables. The point is to use det_id to find which people are assigned to certain row. Here is an example:

select [odpowiedzialny]
from wfelementdetails
left join wfelements
on det_wfdid=wfd_id
where wfd_id=''
and wfd_dtypeid=''
and det_wfconid=''
and det_id=''

In reply to: Arek Maz

You do not need to use "for each operator" .There is an action "run subflow" that you can use on the path. Use this action and pass all the information from subelements list. Action will start new flow for each row. After you pass all necassary info (people also possible but not neccessary) you will need to put an action "create task" on the path in the subflow. Assigning people is available by getting them from subflow form if you pass them, or you can use "sql command" to get them from master flow using wfd_id, det_wfdid, det_id columns from wfelements and wfelementdetails tables. The point is to use det_id to find which people are assigned to certain row. Here is an example:

select [odpowiedzialny]
from wfelementdetails
left join wfelements
on det_wfdid=wfd_id
where wfd_id=''
and wfd_dtypeid=''
and det_wfconid=''
and det_id=''

But if I dont do for each row .. then I will not have 3 subflows (or more - depends how many rows will be in that Item list) ....

and I need for each row to start subflow

or you mean to start sql subflow

https://docs.webcon.com/pl/docs/2024R1/Studio/Action/Workflow/StartManyWorkFlows/
and https://kb.webcon.pl/startowanie-obiegu-z-zewnetrznego-systemu-akcje/

OK, I will need to try tomorrow ...
it will skip not bps users? and what if any of "people" in row is not bps >> than how to assign to another "fellow" ? I guess, it will return error or will ship row with out subflow .... :|

In reply to: Paweł Tołoczko

But if I dont do for each row .. then I will not have 3 subflows (or more - depends how many rows will be in that Item list) ....

and I need for each row to start subflow

or you mean to start sql subflow

https://docs.webcon.com/pl/docs/2024R1/Studio/Action/Workflow/StartManyWorkFlows/
and https://kb.webcon.pl/startowanie-obiegu-z-zewnetrznego-systemu-akcje/

OK, I will need to try tomorrow ...
it will skip not bps users? and what if any of "people" in row is not bps >> than how to assign to another "fellow" ? I guess, it will return error or will ship row with out subflow .... :|

If there is no user returned by SQL command or rule that you used then you will get the error on the path starting subflow. It depends also on what type of step you use (system steps does not need to assign tasks). Source of your user list does not matter. You can use BPS users, AD or Azure for example. You can also use groups of users in the same way. If you want to direct task to certain groups of users, like BPS users, you need to filter them as Jacek mentioned by BPSid or other, or assign them to specific groups.

In reply to: Arek Maz

If there is no user returned by SQL command or rule that you used then you will get the error on the path starting subflow. It depends also on what type of step you use (system steps does not need to assign tasks). Source of your user list does not matter. You can use BPS users, AD or Azure for example. You can also use groups of users in the same way. If you want to direct task to certain groups of users, like BPS users, you need to filter them as Jacek mentioned by BPSid or other, or assign them to specific groups.

Thank you guys but I think I will start from beginning - I have a bad day today and I'm having trouble connecting the "dots".

From begining:
1. Item list (mix names form other flow not connected with any source so ID befor # is random) >> _Wszyscy Audytorzy
2. This Item list (_wszyscy audytorzy) is used in another Item list "Harmonogram Audytu / Kontroli" in field "Odpowiedzialny".
after filing full item list I would like to move to next step the "parent element" and start for each row new work flow.
3. Each sub work flow I would like to assigne to all people in cell row/column >> but:
if non of people: 123123#janek;123123223#bonifacy;12312#john is not a BPS user then assign to person from field "_Audytor Wiodący" (tech field) or whatever
if 1 or 2 or all people are BPS users then assign subwork flow to them,

at the moment I can start subworkflow (no sql - sorry I don't understand how to config the source tab to have proper data so ... I skipped that to "normal" "start subflow"
I understand I can do subflow with out for each but .. I can't config it in proper way....

So I did that:
I do for each row
inside i do just for check condition with sql >> but it returns all time false :| - probably by this random stuff before name ..any way is not working :|
i try to do this (chatGPT):
[code]
IF EXISTS (
SELECT
COS_BpsID,
COS_Login,
COS_IsActive,
COS_AD_name,
COS_AD_mail,
COS_AD_userprincipalname
FROM
CacheOrganizationStructure
WHERE
COS_AD_name IN (
SELECT
-- Wyodrębnij część tekstową po znaku '#'
SUBSTRING(item, CHARINDEX('#', item) + 1, LEN(item))
FROM
dbo.SplitToTable('{SN:936}', ';')
)
)
BEGIN
SELECT 1;
END
ELSE
BEGIN
SELECT 0;
END
[/code]
still c**p ... :|

I was even thing maybe other solution like >> in each row add more tech column and by form rule check if names used in "odpowiedzialny" is in bps users ... if yes then put in some techfield1 and in tech2 field put "true"
and if non then empty tech1 and "false" in tech2 and then do in automation to grab false value and easy sub flow and if true then grab field to who assign ... in theory sound easy ... but constract buisnes rule / rule in cell Odpowiedialny ... not realy easy ... :|

in [system] start path I fill other Itemlists in subflow ...

I guess ..if I could manage assigments then should be easy to do similar way to create Tech item list in sub flow with 2.2.2 i row 1 and 2.2.3 in row 2 and do automation for each row to fill Item list with questions .. but this is not the main issue ....

Probably is easy way to solve my problem but i don't see it ..

In reply to: Paweł Tołoczko

Thank you guys but I think I will start from beginning - I have a bad day today and I'm having trouble connecting the "dots".

From begining:
1. Item list (mix names form other flow not connected with any source so ID befor # is random) >> _Wszyscy Audytorzy
2. This Item list (_wszyscy audytorzy) is used in another Item list "Harmonogram Audytu / Kontroli" in field "Odpowiedzialny".
after filing full item list I would like to move to next step the "parent element" and start for each row new work flow.
3. Each sub work flow I would like to assigne to all people in cell row/column >> but:
if non of people: 123123#janek;123123223#bonifacy;12312#john is not a BPS user then assign to person from field "_Audytor Wiodący" (tech field) or whatever
if 1 or 2 or all people are BPS users then assign subwork flow to them,

at the moment I can start subworkflow (no sql - sorry I don't understand how to config the source tab to have proper data so ... I skipped that to "normal" "start subflow"
I understand I can do subflow with out for each but .. I can't config it in proper way....

So I did that:
I do for each row
inside i do just for check condition with sql >> but it returns all time false :| - probably by this random stuff before name ..any way is not working :|
i try to do this (chatGPT):
[code]
IF EXISTS (
SELECT
COS_BpsID,
COS_Login,
COS_IsActive,
COS_AD_name,
COS_AD_mail,
COS_AD_userprincipalname
FROM
CacheOrganizationStructure
WHERE
COS_AD_name IN (
SELECT
-- Wyodrębnij część tekstową po znaku '#'
SUBSTRING(item, CHARINDEX('#', item) + 1, LEN(item))
FROM
dbo.SplitToTable('{SN:936}', ';')
)
)
BEGIN
SELECT 1;
END
ELSE
BEGIN
SELECT 0;
END
[/code]
still c**p ... :|

I was even thing maybe other solution like >> in each row add more tech column and by form rule check if names used in "odpowiedzialny" is in bps users ... if yes then put in some techfield1 and in tech2 field put "true"
and if non then empty tech1 and "false" in tech2 and then do in automation to grab false value and easy sub flow and if true then grab field to who assign ... in theory sound easy ... but constract buisnes rule / rule in cell Odpowiedialny ... not realy easy ... :|

in [system] start path I fill other Itemlists in subflow ...

I guess ..if I could manage assigments then should be easy to do similar way to create Tech item list in sub flow with 2.2.2 i row 1 and 2.2.3 in row 2 and do automation for each row to fill Item list with questions .. but this is not the main issue ....

Probably is easy way to solve my problem but i don't see it ..

To check if user is in a certain source/table you can do inner join by login, BPSid, etc., or left join with null filter. But SQL you have beedn already given is all you need.
You can add two actions of assignin task and run them on condition that there are BPS users or not. For example, Action 1 - if exists BPS user = True >> run action and assign to BPS user, Action 2 - if exists BPS user = False >> run this action and assign to non BPS user.

All you need is to take all the data from your list and put it in "run subflow" action. Thats it. You don't need to add any tech columns etc. because it is unnecessary data, but if it is easier for you to put checking rule in that way, you can do that. However, it won't give you much, since you still need to filter who is BPS user and who is not.

Still, I do not mind why you are trying to use "for each row" operator? Run sublows by dedicated actions firstly, with all necessary data, and then check your users and assign tasks within subflows.

MVP
In reply to: Paweł Tołoczko

Thank you guys but I think I will start from beginning - I have a bad day today and I'm having trouble connecting the "dots".

From begining:
1. Item list (mix names form other flow not connected with any source so ID befor # is random) >> _Wszyscy Audytorzy
2. This Item list (_wszyscy audytorzy) is used in another Item list "Harmonogram Audytu / Kontroli" in field "Odpowiedzialny".
after filing full item list I would like to move to next step the "parent element" and start for each row new work flow.
3. Each sub work flow I would like to assigne to all people in cell row/column >> but:
if non of people: 123123#janek;123123223#bonifacy;12312#john is not a BPS user then assign to person from field "_Audytor Wiodący" (tech field) or whatever
if 1 or 2 or all people are BPS users then assign subwork flow to them,

at the moment I can start subworkflow (no sql - sorry I don't understand how to config the source tab to have proper data so ... I skipped that to "normal" "start subflow"
I understand I can do subflow with out for each but .. I can't config it in proper way....

So I did that:
I do for each row
inside i do just for check condition with sql >> but it returns all time false :| - probably by this random stuff before name ..any way is not working :|
i try to do this (chatGPT):
[code]
IF EXISTS (
SELECT
COS_BpsID,
COS_Login,
COS_IsActive,
COS_AD_name,
COS_AD_mail,
COS_AD_userprincipalname
FROM
CacheOrganizationStructure
WHERE
COS_AD_name IN (
SELECT
-- Wyodrębnij część tekstową po znaku '#'
SUBSTRING(item, CHARINDEX('#', item) + 1, LEN(item))
FROM
dbo.SplitToTable('{SN:936}', ';')
)
)
BEGIN
SELECT 1;
END
ELSE
BEGIN
SELECT 0;
END
[/code]
still c**p ... :|

I was even thing maybe other solution like >> in each row add more tech column and by form rule check if names used in "odpowiedzialny" is in bps users ... if yes then put in some techfield1 and in tech2 field put "true"
and if non then empty tech1 and "false" in tech2 and then do in automation to grab false value and easy sub flow and if true then grab field to who assign ... in theory sound easy ... but constract buisnes rule / rule in cell Odpowiedialny ... not realy easy ... :|

in [system] start path I fill other Itemlists in subflow ...

I guess ..if I could manage assigments then should be easy to do similar way to create Tech item list in sub flow with 2.2.2 i row 1 and 2.2.3 in row 2 and do automation for each row to fill Item list with questions .. but this is not the main issue ....

Probably is easy way to solve my problem but i don't see it ..

Hi,
the first problem is that you have some numbers as ID in the 'Odpowiedzialny' field (I would expect logins or BPS_ID here ;))? what do these numbers mean and where do you have the logins of these users?

In reply to: Jacek Wojnar

Hi,
the first problem is that you have some numbers as ID in the 'Odpowiedzialny' field (I would expect logins or BPS_ID here ;))? what do these numbers mean and where do you have the logins of these users?

I didn't think about that ...

in the "First" process I do dictionary of Auditors ... Auditors are from AD (IT limitation to BPS accounts :| )
So each user have got flow where I set user properties (build dictionary) of what he can do [have certificates]
-> sooner or later they will have BPS account but in moment of creation dictionary they don't.

Later by few flows I use those people ones grabbed from that flow [source] to pick them to proposal of Audit.
then I do set of proposals of audits for the year and change in previous flows tech field to see them in this "Parent flow"
where I pick signature of proposal of Audit and then filing the form (2 item lists + 1 field) and by sub flows I can do last changes of "party" (participants)
where I can add to that 2 lists users outside of company (with out any account) or AD users or Users from process (the "Dictionary")
then by any update of that 2 lists or 1 field I do "_wszyscy audytorzy" list to pick from that list people to schedule item list (this one where I can pick few people and I would do assign subflows ...

so ....

those ID are from field in other flows where I pick people from AD + people outside company (people outside of course are not in this flow)