You are viewing limited content. For full access, please sign in.

Question

Question

Issue Converting NVARCHAR to VARBINARY in Laserfiche Workflow Custom Query

asked on February 9 Show version history

Hello,

I've successfully created and tested a stored procedure in SSMS. It executes perfectly with the following query:

-- Example execution of the stored procedure
DECLARE @UserSID NVARCHAR(MAX) = '0x010500000000000515000000A065CF7E784B9B5FE77C8770F8010000' -- Example SID in hexadecimal string format
EXEC [dbo].[cspGetUserGroups] @UserSID

However, when I attempt to execute this stored procedure within a Laserfiche Workflow using the Custom Query activity with the query:

EXEC [dbo].[cspGetUserGroups] @UserSID

and setting the parameter as follows:

  • Parameter Name: @UserSID
  • Type: String
  • Parameter Value: %(UserSID) (where %(UserSID) is a token holding a static SID value)

I encounter an error: "Error converting data type nvarchar to varbinary." This error does not occur when I input the static SID value directly as the parameter value.

It seems like the conversion from NVARCHAR to VARBINARY, which is handled within the stored procedure, is causing issues when executed from Laserfiche Workflow. Here's the relevant portion of my stored procedure:

@UserSID NVARCHAR(MAX) -- Changed from VARBINARY(MAX) to NVARCHAR(MAX)
AS
BEGIN
    DECLARE @BinaryUserSID VARBINARY(MAX) = CONVERT(VARBINARY(MAX), @UserSID, 1);
    -- Use of @BinaryUserSID in the procedure

I'm puzzled about why this conversion error is happening, given that the procedure is supposed to handle the conversion internally. Any insights or suggestions on how to resolve this issue would be helpful!

 

Edit: Although I have not found a fix when testing the query, publishing and running my workflow resolves the error and returns the expected data.

1 0

Replies

replied on February 9

I wonder if the parameter is not getting passed from Workflow into your query in the format you expect, so when it gets to the point of converting it, it is failing.

In Workflow, on the Custom Query Editor, what Type(s) do you have selected for your parameter(s)?  Is it set to Default or something else?

0 0
replied on February 9 Show version history

Hey Matthew,

I've tried changing the type to several different options in a sort of Hail Mary attempt to get it working, but unfortunately, I keep hitting the same wall. Whether I set the type to Default or String, the error persists. What's peculiar is that everything works flawlessly when I input the SID directly as the parameter value. The issue only arises when I attempt to use the token as the parameter value.

Edit: I'm starting to think there might be an issue with how the SID is being inserted as a static value into the token itself, but I'm at a loss for what else to try.

0 0
replied on February 9

And the token you have in Workflow is just the text, you are not including the surrounding single quotes (Workflow adds them automatically), correct?

Yes:  0x010500000000000515000000A065CF7E784B9B5FE77C8770F8010000

No:  '0x010500000000000515000000A065CF7E784B9B5FE77C8770F8010000'

0 0
replied on February 9

This is what I have set the token value as that produces the error:

Token Tag is set as a String.

0 0
replied on February 9

Darn - those are the two main issues I've seen with this kind of stuff myself.

Unfortunately, I don't have any really good suggestions regarding what to try next, other than perhaps creating simplier versions of your stored procedure and your workflow to try to confirm whether or not it really looks like it is failing where and how it looks like it is failing, and maybe pinpoint why.  I would make simplier SPs that just take the starting value and pass it right back, then one that takes the starting value, converts it, and passes it right back, each one a little more complex, etc.  Then the workflow just runs that simple SP and uses a "Track Tokens" activity to report back what all the tokens look like.  That doesn't necessarily solve the problem, but it could help confirm whether or not the error is actually happening where it appears to be happening, or elsewhere in the process.

But, there are a lot of really smart people on this forum, maybe someone else has a better idea.  Good luck!

0 0
replied on February 12

Hey Matthew,

I appreciate you at least taking a shot at it! It's definitely an odd nut to crack. Do you know of anyone I can ping that might have another suggestion?

0 0
replied on February 12

You can contact your Solution Provider and if needed they can contact Laserfiche.

0 0
replied on February 12

Hey Blake,

It’s great to hear from you again! I’ll be attending Laserfiche Empower this year. If you’re planning to go as well, it would be nice to catch up in person.

I’ll verify we have enough support hours to cover this issue. Based on the current configuration, the behavior the workflow is exhibiting seems unusual, doesn’t it? I’d appreciate your insight on whether my assessment is correct.

Thank you,

Jarrett

0 0
replied on February 12

Jarrett,

Yep, I'll be there. Hopefully they'll have an app or something that can be used to talk to other attendees. Look forward to seeing you there.

If you have paid your annual support renewal, you can contact your Solution Provider with any issues you are having, and they can reach out to Laserfiche if needed. Since this is an error from that you are only seeing when using Workflow, it should qualify without needing to use any supplemental support agreement you might have with your Solution Provider.

I will say that there is something things that SSMS will do automatically for you without you really knowing it's doing it. I've never run into the issue you are having, so I can't say for sure if this would be one of them. It would explain why you don't see the error when using SSMS but are seeing it when using Workflow. Do you have a way to possibly kick it off using another application to see if it throws the error?

1 0
replied on February 12

Great to hear! I recall there being an app mentioned, though I'm not entirely sure if attendees can use it for communication.

Regarding the solution provider, I'll submit a ticket pronto. Currently, I don’t have an application to initiate the stored procedure. However, I could possibly use an SSRS Report as a workaround.

Thanks a lot for the guidance. Looking forward to catching up in a couple of months!

1 0
You are not allowed to follow up in this post.

Sign in to reply to this post.