I am trying to execute a complex search of the following type and keep getting "parameter invalid". The logic of the search is like this:( (DOCNUM = 1 AND VERSION = 1) OR (DOCNUM = 2 AND VERSION = 1) OR (DOCNUM = 2 AND VERSION = 2) )I'm trying the following code to build my search query, what am I doing wrong? IManOrQuery masterQuery = new ManOrQueryClass();IManOrQuery q1 = masterQuery.AddOrQuery();IManAndQuery andq1 = q1.AddAndQuery(); aq1.AddFieldQuery(imProfileAttributeID.imProfileDocNum).Values.Add("1");aq1.AddFieldQuery(imProfileAttributeID.imProfileVersion).Values.Add("1");IManAndQuery andq2 = q1.AddAndQuery();aq2.AddFieldQuery(imProfileAttributeID.imProfileDocNum).Values.Add("2");aq2.AddFieldQuery(imProfileAttributeID.imProfileVersion).Values.Add("1");//dbList contains a manstrings object with my DBsession.WorkArea.SearchDocumentsEx(dbList, masterQuery);
I am trying to search for specific documents based on complex criteria that will change. My sample was just an example of one of the basic searches I tried in an effort to figure out what my syntax error was.
var orQuery = new ManOrQuery();var aq1 = orQuery.AddAndQuery();var aq1DocNum = aq1.AddFieldQuery(imProfileAttributeID.imProfileDocNum);aq1DocNum.Values.Add("100");var aq1Version = aq1.AddFieldQuery(imProfileAttributeID.imProfileVersion);aq1Version.Values.Add("1");var aq2 = orQuery.AddAndQuery();var aq2DocNum = aq2.AddFieldQuery(imProfileAttributeID.imProfileDocNum);aq2DocNum.Values.Add("100");var aq2Version = aq2.AddFieldQuery(imProfileAttributeID.imProfileVersion);aq2Version.Values.Add("2");var aq3 = orQuery.AddAndQuery();var aq3DocNum = aq3.AddFieldQuery(imProfileAttributeID.imProfileDocNum);aq3DocNum.Values.Add("100");var aq3Version = aq3.AddFieldQuery(imProfileAttributeID.imProfileVersion);aq3Version.Values.Add("3");
Yup, that's basically what I'm saying. Not sure why it matters exactly what I'm trying to accomplish, but here it goes.....I have a list of "document/version candidates" from an external source (say a list of recent documents on the PC) and I want to make sure the user still has rights to view those documents by querying the API and finding which ones return from the query (assuming that if someone has removed the user's rights to a document it will not be returned from the complex query). I ended up doing this by retrieving each document separately, but I figured the complex query would let the API do the heavy lifting of "OR"ing the query (instead of me). So much for that. While I'm asking, how come the 8.5 SDK documentation has last updated dates from 2007?
//Inclusive Or Search Example// Create ANDQueryIManAndQuery andQuery = new ManAndQueryClass();// Use AddFieldQuery to create an Or query (ex. DOCNUM="35094")IManFieldQuery andQueryField = andQuery.AddFieldQuery(imProfileAttributeID.imProfileDocNum);andQueryField.Values.Add("35094");// Use AddFieldQuery to build an Or subquery between values of the same attributeID// (ex. VERSION="1" OR VERSION="2" OR VERSION="3")IManFieldQuery oqC1 = andQuery.AddFieldQuery(imProfileAttributeID.imProfileVersion);oqC1.Values.Add("1");oqC1.Values.Add("2");oqC1.Values.Add("3");
IManOrQuery orQuery = new ManOrQueryClass();IManFieldQuery qDoc = orQuery.AddFieldQuery(imProfileAttributeID.imProfileDocNum);qDoc.Values.Add("35088");IManAndQuery oqDoc = orQuery.AddAndQuery();IManFieldQuery oqAndDoc = oqDoc.AddFieldQuery(imProfileAttributeID.imProfileDocNum);oqAndDoc.Values.Add("35094");IManFieldQuery oqAndDocVer = oqDoc.AddFieldQuery(imProfileAttributeID.imProfileVersion);oqAndDocVer.Values.Add("2");oqAndDocVer.Values.Add("3");
IManAndQuery andQuery = new ManAndQueryClass();IManFieldQuery oqVer = andQuery.AddFieldQuery(imProfileAttributeID.imProfileVersion); oqVer.Values.Add("2");oqVer.Values.Add("3");IManOrQuery oqDoc = andQuery.AddOrQuery();IManFieldQuery oqAndDoc1 = oqDoc.AddFieldQuery(imProfileAttributeID.imProfileDocNum);oqAndDoc1.Values.Add("35094");IManFieldQuery oqAndDoc2 = oqDoc.AddFieldQuery(imProfileAttributeID.imProfileDocNum);oqAndDoc2.Values.Add("35088");