Home > Forum > Rules, JS, SQL > swimming lane validation

swimming lane validation
0

Hi,

I need to validate a workflow instance against other instances
of the same workflow.

Use case:
- users reserve a resource (swimming lane)
- each instance has StartDate and EndDate
- the same lane cannot be reserved by two instances
for overlapping time ranges

Question:

What is the recommended approach in WEBCON BPS
to implement cross-instance validation?

I tried Custom Action SDK, but it works only
on the current instance.

Thanks.

MVP

Hi Androsh,

if you are comfortable with SQL I would use SQL otherwise you could use a BPS internal view. Either one could be used in a "Validate form" action.

In general I would do something like "Count the number of workflow instances which reserve the swimming lane in the same time frame and is not the current instance. ". If the number is 0, then everything is fine.

If the swimming lane is a workflow instance and not an item list row it would be something like:

select Count(*)
from
(
select WFD_ID, WFD_STPID,
from WFElements
where WFD_DTYPEID = SwimmingLaneProcesses
and WFD_ID <> 'CurrentInstanceId'
and WFD_SwimmingLaneField = 'SwimmingLane'
and
(
(WFD_AttStartDateField between 'Start Date' and 'EndDate) or
(and WFD_AttEndDateField between 'Start Date' and 'EndDate)
)
)
as OtherRowsUsingTheSwimmingLane

This could be used as a SQL Command in the Validate action and compare the result against >0

Alternatively you could directly return True (1) / False (0). For some reason I prefer the "Count" variant, maybe because we can switch the "SQL Command" with "Data source Value".

Best regards,
Daniel

MVP
In reply to: Androsh

Hi, Daniel

Thank you for your advice, I would be grateful if you could point me to the right documentation where I can find this "Validation Form", there is so much info on different versions, example: https://community.webcon.com/posts/post/the-validate-form-action/189/18 I dont think you can do as such as in this post/link.

Best regards,

Hi Androsh,

you found a good explanation for it. :)
This example:

Fig. 9. The configuration of the validation action using the SQL expression

is similar to the one I had in mind. The biggest difference is, that I directly use the result of the if condition.

Here's also the official documentation from the help file, but the knowledge base example is better :)
https://docs.webcon.com/docs/2026R1/Studio/Action/Form/Action_ExecuteValidationQuery

One drawback is, that this "Validate form" action can only be used in a path transition or save action, but it may be sufficient in your case.


Best regards,
Daniel

MVP
In reply to: Androsh

Hi Daniel,
Thank you very much for info, but I think I dont understand syntax a little bit in this WEBCON Validation form, I get this error after trying to make Select(Picture 1).

Error:

Error occured during business rule evaluation.
Error getting data for DataConnection BPS_InternalConnection ID: 1 (Current BPS database)

Incorrect syntax near the keyword 'AND'.

at: Evaluation requested
at: Evaluation node: SQL

Best regards,

Hi Androsh,

if you are running into these kind of issues I recommend to click on the "Show" button and execute the displayed statement in SQL Management Studio. This way you will get some syntax checks which makes it easier.

In your case there will be something like this

and WFD_AttChoose2 = MyUnquotedStringValueWhichCausesTheIssue
and
(
WFD_AttDateTime1 < 2026-02-01-20-03 -- Oh an arithmetic expression, so let's calculate the value wich is 2000;)


I would also recommend to use the "Objects" tab to use the variables instead of hardcoding the database field names. This will make it easier to read. ;)

I've used the between example because of a situation like this
- Swim lane 1 is reserved from 14:00 to 15:30
- Another one wants to reserve the swim lane from 14:30 to 15:00

This would be allowed with the current condition in your example.

At least if the users can select the timeframe manually. Depending on whom is going to use the application, I would test whether using a dictionary for the time slots is more user friendly than selecting the time. Assuming that all lines are available at the same time frames
Mo 14:00 -14 :45
Mo 14:45 - 15:30
Mo 15:30 - 16:15
Tu 13:15 - 14:00

Then the user could select the date from which the weekday could be derived and the drop down would display the available time slots. These could either be all available from the dictionary or only those which haven't been used by another workflow instance yet.

Best regards,
Daniel

In reply to: Daniel Krüger (DCCS)

Hi Androsh,

if you are running into these kind of issues I recommend to click on the "Show" button and execute the displayed statement in SQL Management Studio. This way you will get some syntax checks which makes it easier.

In your case there will be something like this

and WFD_AttChoose2 = MyUnquotedStringValueWhichCausesTheIssue
and
(
WFD_AttDateTime1 < 2026-02-01-20-03 -- Oh an arithmetic expression, so let's calculate the value wich is 2000;)


I would also recommend to use the "Objects" tab to use the variables instead of hardcoding the database field names. This will make it easier to read. ;)

I've used the between example because of a situation like this
- Swim lane 1 is reserved from 14:00 to 15:30
- Another one wants to reserve the swim lane from 14:30 to 15:00

This would be allowed with the current condition in your example.

At least if the users can select the timeframe manually. Depending on whom is going to use the application, I would test whether using a dictionary for the time slots is more user friendly than selecting the time. Assuming that all lines are available at the same time frames
Mo 14:00 -14 :45
Mo 14:45 - 15:30
Mo 15:30 - 16:15
Tu 13:15 - 14:00

Then the user could select the date from which the weekday could be derived and the drop down would display the available time slots. These could either be all available from the dictionary or only those which haven't been used by another workflow instance yet.

Best regards,
Daniel

Hi Daniel,

May I ask a few questions regarding AssemblyVersion in code and Application Export.
Is there anything I can do to not use for example: [assembly: AssemblyInformationalVersion("1.0.0.3")]
but rather 1.1.$([System.DateTime]::UtcNow.ToString(yyMdd.hhmmff)) or sort of because as of now I found only UTCfunction sort of.
1. About Application Export, there is no way to import from WEBCON forexample 2026 1.2 to 2026 1.3 or can it be edited somewhere using notepad etc in file?
2. Can you export Application instances export? I have for example 20 reservations finished. When I exported Application using this instruction: https://community.webcon.com/posts/post/importing-and-exporting-applications-in-webcon-bps/209/4 , evrything was fine until I understood I dont have instances of reservations

Thank you in advance again guru :),

Best regards,