cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Queries in the Unity API

Brandon_Miller
Champ on-the-rise
Champ on-the-rise

Hello,


I'm trying to create a script that will pull documents based off of a custom query I have set up. The custom query itself works fine in the client, but when I try to connect to the api via a script and run the query I am getting a NullReference exception. Has anyone else ever experienced this? The Hyland.Unity.dll version is 16.0.2.83. Even the if statement errors out. Like the CustomQueries library doesn't exist in the API or something.. Do we need a special license type to accomplish this?


if(app.Core.CustomQueries != null)            {                try                {                    Console.WriteLine(app.Core.CustomQueries.Count);                }                catch (UnityAPIException ex)                {                    Console.Write(ex);                    app.Dispose();                }            }
1 ACCEPTED ANSWER

Marcus_Christi2
Elite Collaborator
Elite Collaborator

Speculating because there isn't enough information. Is this run outside (Unity API) or inside (Unity Automation API)? If it's outside are you connecting Session first?


Also, I could be totally off, but I don't think you can test null against app.Core.CustomQueries like that without instantiating it first.


Mind, if this is just a snippet you may have accounted for these.

View answer in original post

5 REPLIES 5

Marcus's code is excellent and correct. That is the general structure of how a CustomQuery object is instantiated and used by the DocumentQuery class.