Home > Forum > Database > SQL Query to get the User Cal in a workflow

SQL Query to get the User Cal in a workflow
0

Hi all!

I need to create an email alert that will be triggered if a Task Assignment Workflow is created for a specific user. My goal is to check if that user is a User Cal (has a Webcon licence) and if not send me an email so I can give the user the access required.

I've created a Send custom email and I'm trying to define the execution rule that will be checking the previous statement.
My query is the following:

SELECT UCL_BpsID
FROM WFElements
JOIN CacheOrganizationStructure as G ON {WFCONCOL:1858} = G.COS_BpsID
JOIN UsersCal as A ON G.COS_BpsID = A.UCL_BpsID
where WFD_ID = '{WFD_ID}'

I actually want to get the UCL_LicenseType (Integer denoted license type) associated with the user, I've changed the form field to ID, Database ID/ Name and it retrieves an error all the time.


Does anyone tried this before?

Thank you all

MVP

Hi Andreia,

I wanted to test it, but for some reason my UserCals table is empty. So take the following suggestions with a grain of salt, since I couldn't test them.
1. JOIN UsersCal <- there is an s missing, it should be UsersCals
2. If {WFCONCOL:1858} is a user/choose field, you should use "Database field name - Id"
3. I don't see the reason for using the CacheOrganizationStructure. Without knowing the data I would guess, that this should return the same data:
SELECT UCL_BpsID
FROM WFElements
JOIN UsersCals as A ON A.UCL_BpsID = 'ID OF USER'
where WFD_ID = '{WFD_ID}'

4. If you are executing this on the Task Assignment Workflow, you could simply use the Login option for the field from the Values tab
SELECT UCL_BpsID
FROM UsersCals
where UCL_BpsID = 'ID OF USER'

The numbers in the images refer to the numbers above.
If you are having trouble with choose fields/sql statements you could spend a few minutes here:
https://daniels-notes.de/posts/2021/series-expert-guide-part-4#querying-chooseperson-fields
https://daniels-notes.de/posts/2021/series-expert-guide-part-3#creating-the-sql-statement

I hope there is some helpful information here and in the posts.

I'm not sure way you need this at all. My only idea is, that you are running out of Cals and you need to release one. But that's not the question here anyway. :)


Best regards,
Daniel

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

Hi Andreia,

I wanted to test it, but for some reason my UserCals table is empty. So take the following suggestions with a grain of salt, since I couldn't test them.
1. JOIN UsersCal <- there is an s missing, it should be UsersCals
2. If {WFCONCOL:1858} is a user/choose field, you should use "Database field name - Id"
3. I don't see the reason for using the CacheOrganizationStructure. Without knowing the data I would guess, that this should return the same data:
SELECT UCL_BpsID
FROM WFElements
JOIN UsersCals as A ON A.UCL_BpsID = 'ID OF USER'
where WFD_ID = '{WFD_ID}'

4. If you are executing this on the Task Assignment Workflow, you could simply use the Login option for the field from the Values tab
SELECT UCL_BpsID
FROM UsersCals
where UCL_BpsID = 'ID OF USER'

The numbers in the images refer to the numbers above.
If you are having trouble with choose fields/sql statements you could spend a few minutes here:
https://daniels-notes.de/posts/2021/series-expert-guide-part-4#querying-chooseperson-fields
https://daniels-notes.de/posts/2021/series-expert-guide-part-3#creating-the-sql-statement

I hope there is some helpful information here and in the posts.

I'm not sure way you need this at all. My only idea is, that you are running out of Cals and you need to release one. But that's not the question here anyway. :)


Best regards,
Daniel

Hi Andreia,
The UsersCals table is only applicable in WEBCON APPS Subscriptions. The Licensing model is a little bit different than the rest of the BPS installation types.
If you need some help with your Subscription, please issue a ticket on our Support Platform (https://support.webcon.com).

Best regards,
Tomasz