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

Question

Question

Web Access Custom Action Error: Invalid Connection

asked on June 8, 2016

Hey! I need a bit of help creating a custom button in Web Access 9.2 that retrieves a field value off of a selected document and then uses that field value to generate and ultimately open a URL within the user's browser (as a new tab). Essentially, I'm trying to do exactly what is described in EDM 302: Advanced Web Customizations from Empower 2014 (within that course folder, see the Part 2 [URL integration by Field Value] Server DLL sub-folder).

The problem that I appear to be hitting is in trying to retrieve the active LFSO database object from the current Web Access session. Specifically, the following lines of code are erroring out:

// Retrieve the active LFSO database object from the current Web Access Session
WebAccessSession WASession = WebAccessSession.GetSessionObject();
ILFDatabase db = WASession.ConnectionManager.GetLoggedInRepository();

To be precise, the last line is what throws the exception. The exception is:

(I got that error message to appear by changing the Empower course's sample CustomActions.xml file to `alert(err.get_message)` when `onWebServiceCallFail` is called. I get the error after clicking the custom toolbar button, which appears fine in my Web Access toolbar.)

Just in case it's helpful, here is the exact code that I'm running on my end:


(Note: In the .cs file, I've commented out the code to get the field value, just in my troubleshooting attempts to isolate the issue. FWIW: If I comment out all of the code that attempts to clone the user's connection, Web Access opens my hardcoded google.com link just fine. So, I know the problem is with the connection cloning code.)

As instructed in the course handout, I am recompiling the WebAccessCustomActions.dll file each time that I update CustomActions.cs, and I move the updated .dll into C:\Program Files\Laserfiche\Web Access\Web Files\bin).

In case it matters, the user in question does have access to the relevant template and field (which are named identically in my repository as they are in the course's sample code).

Right now I'm strictly trying to get the sample code from the Empower course to work in my environment. When I get this working, I'll work backwards to create my own custom button/action. That said, I haven't been able to get the course code working yet.

Any ideas?

0 0

Replies

replied on June 8, 2016

You might start by changing the onWebServiceCallFail code to alert(err.get_message()) (note the extra parens), since what you're seeing there is a javascript function body and does not necessarily have anything to do with the actual error.  Calling the function should get the error message.

1 0
replied on June 9, 2016

Hey Andrew! Good call!

I made the change that you suggested, and you're right, I am now seeing the actual exception that I'm hitting:

So, it looks likes like the `GetLoggedInRepository()` method doesn't exist in my environment? That is odd, because when I edit CustomAction.cs in Visual Studio (which is inside of the Empower course's WebAccessCustomActions.sln file), I don't see any errors (the WebAccessCustomActions.dll file compiles just fine).

Any ideas why this method would be missing?

It looks like the `GetSessionObject()` method does exist, which is also a member of the `WebAccessSession` object.

0 0
replied on June 9, 2016

Ah, I figured out the issue (thanks to Andrew's help).

The Empower course's Visual Studio solution was bundling WebAccessCommon.dll version 9.1, where as my environment was using  WebAccessCommon.dll version 9.2 (it was also using LFSO 9.1 instead of LFSO 9.2). I made a wholesale switch of all 9.1 references to 9.2, and now everything works fine.

I'm not exactly sure why this would break things, since both WebAccessCommon.dll version 9.1 and version 9.2 contain a `GetLoggedInRepository()` method.

0 0
replied on June 9, 2016

Also, just an FYI for anyone else that tries this, I had to add a reference to Microsoft.CSharp.dll to my Visual Studio solution. I was seeing other errors until I did so.

0 0
replied on June 9, 2016

Yeah, if you had WebAccessCommon 9.2, then the error message is literally correct: there is no GetLoggedInRepository method that returns an LFSO91Lib.LFDatabase object (the 9.2 version returns LFSO92Lib.LFDatabase).  As far as Visual Studio knows, these two types need not have anything to do with each other.

The using directives make this type mismatch less obvious at a glance, though.

0 0
replied on June 9, 2016

Gotcha. That makes sense. Thanks Andrew!

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

Sign in to reply to this post.