Skip to main content
Nintex Community Menu Bar

Sqlexception when use GetWorklistItems method

  • July 19, 2022
  • 5 replies
  • 48 views

Forum|alt.badge.img+4

Hi All!

 

We call a GetWorklistItems method in our service (C# and Client DLL) and there is an error in hostserver log

System.Data.SqlClient.SqlException (0x80131904): Incorrect syntax near ')'. Must declare the scalar variable ""@User"". Incorrect syntax near the keyword 'with'....

 

We use sql profiler to catch what sql code run this time. I don't find this code in K2 DB. Please help how can we solve this problem!

 

I attached whole error and sql.

 

Thanks in advance

Laszlo

5 replies

JRoberts
Nintex Employee
Forum|alt.badge.img+12
  • Nintex Employee
  • July 25, 2022

Hi Laszlo,

 

I'm assuming your service code is using the SourceCode.Workflow.Management API when calling GetWorklistItems().

 

First, double check to make sure the account making the call for the worklist has Admin rights to K2. If it does and you're still seeing SQL Server kick this error, I would suggest opening a ticket with Nintex support to see if they can help you dig deeper. 

 

Jason


  • Nintex Employee
  • July 27, 2022

Did it work previously and now it doesn't?

If you capture the SQL and execute it in SSMS, do you still get the error?


Forum|alt.badge.img+4
  • Author
  • Rookie
  • July 28, 2022

Hi David!

 

I think i found the problem. We use a filter before call GetWorklistItems to filter a special serial numbers and actions to the user.

 

This is the part of the code:

 

foreach (var item in serialNumbers)
{
var splitted = item.Split('_');
var procinstid = int.Parse(splitted[0]);
var activity = int.Parse(splitted[1]);

wCrit.AddRegularFilter(WorklistFields.ProcInstID, Comparison.Equals, procinstid, RegularFilter.FilterCondition.OR_OPEN);
wCrit.AddRegularFilter(WorklistFields.ActInstDestId, Comparison.Equals, activity, RegularFilter.FilterCondition.AND_CLOSE);
}

WorklistItems wlistitems = wms.GetWorklistItems(wCrit);

 

If the number of the serialNumbers is greater than 95 the error will occur

 


  • Nintex Employee
  • July 28, 2022

It has been a while since I have used this API.   It looks like you are maintaining a list of serial numbers assigned to a user.  Here are some ideas:

1. Tasks by their nature are assigned to a user or group.  Could you change the criteria to filter by user?

2.  You could filter the list as narrow as possible with simple criteria, then use something like LINQ to  filter the initial collection by process instance and activity destination instance.


Forum|alt.badge.img+4
  • Author
  • Rookie
  • July 29, 2022

Thanks for help, at first I'll create a new case to the support because it's seems very easy to fix the dynamic slq (change DECLARE @paramlist NVARCHAR(4000) to DECLARE @paramlist NVARCHAR(Max))