Home > Forum > Actions > Global actions - On start (cyclical) - Error description ?

Global actions - On start (cyclical) - Error description ?
0

Account deleted

Hello everyone

In a process I run a cyclic action in the Global Actions. This action contains a "Start a subworkflow (SQL)".
When the subworkflow action is executed I just get the message 'Incorrect syntax near '}'.' in the *Last error* field. As seen on the screenshot

There is no '}' in the SQL query of the subworkflow action...
So now I am facing the mystery where exactly this error occurs at all and what exactly is the cause.
Does anyone know where I can find more information about the error? (Without ACTID or GUID I can't search for errors in the administration tool. Where else could I search?)

Thanks in advance!

**
The subworkflow directly follows a path that points only to an end step. No other actions are performed on the path.
I have been able to successfully execute the SQL query in the subworkflow configuration via "Test" without any errors, so I don't think the problem should be with the query itself.
**

Hello Roman,

since you are starting new instances with Start a subworkflow (SQL) - you are creating new instances.
Please take a look at the path (selectec inside configuration of the Start a subworkflow (sql) ) used to create new instance in the process.

I elieve, that you may have there any action which uses syntax with '}' inside. It may be chenge form field action on path with usage of sql syntax.

MVP

Hi,
Is there a possibility to show us the query?

Values from attributes which are displayed in editor as named blocks, are internally represented as {N:AttributeID}, {AttributeID}, {WFD_ID}, {WFD_Signature} for exapmle.
'Incorrect syntax near' is container for a lot of small typos.

Are you sure that the query doesn't need context of data from specific element?
While running global cyclical actions you can't really use 'Values' from picker, because there is no single form which should provide data. `Test` button always works in context of specified element ID.
Query will work with the test button, but while being executed globally it might cause errors.

Account deleted
In reply to: Bartłomiej Spyrka (WEBCON)

Hello Roman,

since you are starting new instances with Start a subworkflow (SQL) - you are creating new instances.
Please take a look at the path (selectec inside configuration of the Start a subworkflow (sql) ) used to create new instance in the process.

I elieve, that you may have there any action which uses syntax with '}' inside. It may be chenge form field action on path with usage of sql syntax.

Hi Bartłomiej

I am not sure if I have understood you correctly.

There is only one path from the start to the end step. This path has no actions. (It is actually planned to have a control step after the start, but I have not yet implemented this because the whole process does not work via the startworkflow).

See WorkflowDesigner. (one path, no actions)
See step config. Actions (the path "SharepointImport" has no actions in it)
See Global (cycl.) Action. (in Basic Tab the process, workflow, formtype, business entity and path is filled in. Nowhere it has a '}'. Advanced tab is empty)

Account deleted
Account deleted
In reply to: Raluca-Mirabela Lupu

Hi,
If you manually start the process, do you receive any errors?
Do you have a query select in the choice field?
It's possible that the error could also come from field configuration.
Do you have any business rule configured with SQL and used on the form?

Regards,
Raluca

Hi Raluca,

Do you mean if I can start the process through the web interface (WebconPortal) by using the "SharepointImport" path?
If that's what you mean, then yes, that works without me getting an error. (I filled in the same form fields as the SQL output).

**
All choice fields have as datasource a dictionary or a fixed values list. (Each choice field has a filter, but this is a "simple" Webcon filter and not a SQL query).
In total I have two business rules, both are not executed in the start step but much later in other steps.
**

Account deleted
In reply to: Raluca-Mirabela Lupu

Hi,
Yes, you can execute the action on the path.
If you get the same error, you can enable "diagnostic mode" and hit the path again. You can see all queries in diagnostic mode.

Thanks,
Raluca

Hi,

Alright, I was able to "partially" solve the problem. It simply led to another problem.

It really looks like the SQL query was the problem. 😒 Not sure why, but it seems to be the named blocks of Webcon. Example {WFCONCOL:1257}
(I didn't even type in the named blocks manually, but rather by using the fields in the SQL query configuration dialog of Webcon).
(And via "Test" in the configuration dialog it always worked, so I excluded the query first - obviously hasty after all)

Here's how I solved the original problem with the syntax error '}':
I enclosed each table attribute with [ and ]. This sanitizes the attribute names.

**
Here I have a question for the Webcon developers. Are SQL queries "interpreted" or "transformed" again in Webcon before they are executed?
Are comments with '--' or '/* */' filtered out?
I noticed that 'ORDER BY' does not work with the 'FROM' table if there is no 'TOP (any number)' in the 'SELECT'.
There is an "Unkown error" in the query test. Even if I comment out the 'ORDER BY' in the query.
As soon as 'TOP (any number)' is present, the 'ORDER BY' works again.
**

Nevertheless, now for my new problem. 😅

The SQL query outputs employee names and fills them into person fields. (Example 'Supervisor' of a requester/author).
The problem now is that I am outputting "some" persons who are no longer employed by the company and therefore are not recognized by Webcon as users because they are not BPS users (BPS ID).
The error "No exact match was found for: 'former employee name'" is displayed.

My question: is there a possibility to insert users that are not available as BPS users into a person field?
(what I found out is that if the employee is in BPS format "user@example.com#User name" it can be inserted regardless of whether the person really exists or not. But since we have several hundred employees I don't know which persons are no longer employed and if I can change the entry on-the-fly at all (example: "no-reply@company.com#former employee name")).

Does anyone have an idea how to solve this?

Thanks a lot in advance.

MVP
In reply to: Account deleted

Hi,

Alright, I was able to "partially" solve the problem. It simply led to another problem.

It really looks like the SQL query was the problem. 😒 Not sure why, but it seems to be the named blocks of Webcon. Example {WFCONCOL:1257}
(I didn't even type in the named blocks manually, but rather by using the fields in the SQL query configuration dialog of Webcon).
(And via "Test" in the configuration dialog it always worked, so I excluded the query first - obviously hasty after all)

Here's how I solved the original problem with the syntax error '}':
I enclosed each table attribute with [ and ]. This sanitizes the attribute names.

**
Here I have a question for the Webcon developers. Are SQL queries "interpreted" or "transformed" again in Webcon before they are executed?
Are comments with '--' or '/* */' filtered out?
I noticed that 'ORDER BY' does not work with the 'FROM' table if there is no 'TOP (any number)' in the 'SELECT'.
There is an "Unkown error" in the query test. Even if I comment out the 'ORDER BY' in the query.
As soon as 'TOP (any number)' is present, the 'ORDER BY' works again.
**

Nevertheless, now for my new problem. 😅

The SQL query outputs employee names and fills them into person fields. (Example 'Supervisor' of a requester/author).
The problem now is that I am outputting "some" persons who are no longer employed by the company and therefore are not recognized by Webcon as users because they are not BPS users (BPS ID).
The error "No exact match was found for: 'former employee name'" is displayed.

My question: is there a possibility to insert users that are not available as BPS users into a person field?
(what I found out is that if the employee is in BPS format "user@example.com#User name" it can be inserted regardless of whether the person really exists or not. But since we have several hundred employees I don't know which persons are no longer employed and if I can change the entry on-the-fly at all (example: "no-reply@company.com#former employee name")).

Does anyone have an idea how to solve this?

Thanks a lot in advance.

Hi Roman,

comments:
The query is passed as it is, -- and /**/ are part of it. Even so single line comments seldom cause problems, it happens.
If you enable the diagnostic mode, you can search the trace for a line from your query and see the executed one. That's far easier than my previous approach to use the SQL Profiler. :)


Users no longer available:
There was once a stored procedure ReplaceLogins which updated logins, but it seems that it was removed in later versions. That would have been an option to update the old users. At least if you want to do it. Of course this would break the audit trail, as this was intended to replace the old user new with a new one, if this changed.
ALTER PROCEDURE [dbo].[ReplaceLogins]
@oldLogin nvarchar(150),
@newLogin nvarchar(150),
@newDisplayName nvarchar(100)
AS
BEGIN


Since this is no longer an option, I would do the following:
Add a dictionary which maps the old users to new ones.
Build a cyclical action which periodically checks the relevant person/choose fields whether a user id used, which is no longer in the CacheOrganizationStructure
Add an entry and send a mail, that something needs to be done.
For example define a new user or fallback user.
In the processes where this could happen you could then map the user for example with some like this
select
...
, isnull((select NewUserId from Dictionary where OldUserId = Author),Author)

If the author still exist, there should be no entry and it would use author, otherwise the new user

The action populating the dictionary should also check, whether a user account is back again, for any reason.


Off topic:
The removed users, was a use case for my first blog post. :)
https://daniels-notes.de/posts/2021/series-expert-guide-part-1#part-overview

Best regards,
Daniel

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

Hi Roman,

comments:
The query is passed as it is, -- and /**/ are part of it. Even so single line comments seldom cause problems, it happens.
If you enable the diagnostic mode, you can search the trace for a line from your query and see the executed one. That's far easier than my previous approach to use the SQL Profiler. :)


Users no longer available:
There was once a stored procedure ReplaceLogins which updated logins, but it seems that it was removed in later versions. That would have been an option to update the old users. At least if you want to do it. Of course this would break the audit trail, as this was intended to replace the old user new with a new one, if this changed.
ALTER PROCEDURE [dbo].[ReplaceLogins]
@oldLogin nvarchar(150),
@newLogin nvarchar(150),
@newDisplayName nvarchar(100)
AS
BEGIN


Since this is no longer an option, I would do the following:
Add a dictionary which maps the old users to new ones.
Build a cyclical action which periodically checks the relevant person/choose fields whether a user id used, which is no longer in the CacheOrganizationStructure
Add an entry and send a mail, that something needs to be done.
For example define a new user or fallback user.
In the processes where this could happen you could then map the user for example with some like this
select
...
, isnull((select NewUserId from Dictionary where OldUserId = Author),Author)

If the author still exist, there should be no entry and it would use author, otherwise the new user

The action populating the dictionary should also check, whether a user account is back again, for any reason.


Off topic:
The removed users, was a use case for my first blog post. :)
https://daniels-notes.de/posts/2021/series-expert-guide-part-1#part-overview

Best regards,
Daniel

Hi Daniel

Thanks for your suggestion.

The table is a static list, the (ex-)employees do not change in it anymore. (It is a migration list from sharepoint to webcon). So I don't see any sense to check the people cyclically via a dictionary.

But I found another way how to import the people anyway (via the startsubworkflow) without getting an error message.
I use the fact that the users have a BPSID (email@company.com#username). So I only have to check in the origin table if there is a user in the CacheOrganizationStructure table, if not I just append "no-reply@company.com#" to the content of the affected field.

This is the SQL query for it:
UPDATE
[ImportJobRequisition]
SET
[Requester] = CASE
WHEN NOT EXISTS (
SELECT
1
FROM
[CacheOrganizationStructure] cos
WHERE
[ImportJobRequisition].[Requester] = cos.[COS_DisplayName]
OR [ImportJobRequisition].[Requester] = cos.[COS_AD_displayname]
)
AND [Requester] NOT LIKE 'no-reply@company.com#%' THEN CONCAT('no-reply@company.com#', [Requester])
ELSE [Requester]
END,
[morePersons] = CASE
WHEN NOT EXISTS (
SELECT
1
FROM
[CacheOrganizationStructure] cos
WHERE
[ImportJobRequisition].[morePersons] = cos.[COS_DisplayName]
OR [ImportJobRequisition].[morePersons] = cos.[COS_AD_displayname]
)
AND [morePersons] NOT LIKE 'no-reply@company.com#%' THEN CONCAT('no-reply@company.com#', [morePersons])
ELSE [morePersons]
END


I could probably run this as an SQL procedure in Webcon, but I don't see much point to that either. It's easy to just run the SQL query on the SQL server itself.

I basically follow the KISS principle. "Keep it simple, stupid!" 😎


Perhaps this will also help someone else with a similar issue in the future.