Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
SearchDocumentsEx error Search parameter invalid
Marco_at_NL
When i run this VBA code with a reference to iManage.dll version 8.2, i always get this error message when exeuting SearchDocumentsEx.
I can't find the problem.. anyone??
[WorkArea ][SearchDocumentsEx ]Search parameter invalid
Sub test()
Dim dms As IManDMS
Dim ses As IManage.IManSession
Set dms = New ManDMS
Set ses = dms.Sessions.Add("vmxp")
dms.Sessions.ItemByIndex(1).Login "nrtadmin", "nrtadmin"
Dim andQ As IManage.ManAndQuery
Dim fld As IManFieldQuery
Dim db As New ManStrings
Dim result
db.Add "Test"
Set andQ = New IManage.ManAndQuery
Set fld = andQ.AddFieldQuery(imProfileAuthor)
fld.Values.Add ses.UserId
Set result = ses.WorkArea.SearchDocumentsEx(db, andQ)
ses.Logout
dms.Close
Set dms = Nothing
End Sub
Thanks
Marco
Find more posts tagged with
Comments
jny
What is your intended search criteria? It doesn't look right to search by an AND Query with just one search value.
Marco_at_NL
My intended search is
CUSTOM2 IN (1,2,3,4...)
using this code:
Set fld = andQ.AddFieldQuery(imProfileCustom2)
fld.Values.Add "1"
fld.Values.Add "2"
fld.Values.Add "3"
but that gave me the same error, so i switch back to a simple example that also raises this error..
Using the OR combination is not a solution, because it will probably result in a too long sql statement when using many values.
Can you reproduce the error using my sample code?
Thanks
Marco
jny
Yes, it errored out as it should've had because it did not look like the correct way to build the search query you wanted.
I think you have to go with the OrQuery. Like so:
Dim orQ As New ManOrQuery
With orQ
.AddOrQuery.AddFieldQuery(imProfileCustom2).Values.Add "1"
.AddFieldQuery(imProfileCustom2).Values.Add "2"
.AddFieldQuery(imProfileCustom2).Values.Add "3"
End With
You might also try:
Dim dms as New ManDMS
Dim ps As IManProfileSearchParameters
'Assuming dms is connected.
Set ps = dms.CreateProfileSearchParameters
ps.Add imProfileCustom2, "1, 2, 3"
Either approach should yield the same results for your query (of custom2="1" Or "2" Or "3").
Marco_at_NL
Have you tried the code? it will give the same error if you add a single value..
Dim orQ As New ManOrQuery
With orQ
.AddFieldQuery(imProfileCustom2).Values .Add "1"
End With
When i run Sql Profiler i see that even if you specify multiple values for a single AddFieldQuery it will construct multiple OR statements.. ..
I will run multiple OrQueries and / or run a separate direct Sql statement over the tables and get the documentnumbers/versions..
Thanks
Marco
jny
Ok, I guess I don't understand what you are trying to accomplish then...why would you add a single value when you wanted to query for custom2 = 1, or, 2, or 3??
Marco_at_NL
According to this sample in the SDK 8.2 it's possible to add multiple values to a single AddFieldQuery. I assumed in this case it will construct an IN (...) query instead of OR .. OR .. OR, but in Sql Profiler i see that in both cases it's creating an OR .. OR .. OR query...
Example B – Search Query: (AUTHOR=) AND (CLIENT="C1A"
OR CLIENT="C1B" OR CLIENT="1235") AND (CLASS="E-MAIL" OR TYPE="MIME")
private void ExampleB(IManSession sess, ManStrings dblist)
{
// Search Query: (AUTHOR=) AND (CLIENT="C1A" OR
// CLIENT="C1B" OR CLIENT="1235") AND (CLASS="E-MAIL" OR TYPE="MIME")
// Create AndQuery
IManAndQuery andQuery = new ManAndQueryClass();
// Use AddFieldQuery to create an AND query (ex.
AUTHOR=)
IManFieldQuery andQueryField = _
andQuery.AddFieldQuery(imProfileAttributeID.imProfileAuthor);
andQueryField.Values.Add(sess.UserID);
// Use AddFieldQuery to build an Or subquery between values of the
// same attributeID (e.g., CLIENT="C1A" OR CLIENT="9102" OR
// CLIENT="1235" OR CLIENT="5679")
IManFieldQuery oqC1 = _
COM Object for WorkSite Developer’s Reference Guide Lesson 6: WorkSite Searches
Interwoven 06/06 Page 65
andQuery.AddFieldQuery(imProfileAttributeID.imProfileCustom1);
oqC1.Values.Add("C1A");
oqC1.Values.Add("9102");
oqC1.Values.Add("1235");
oqC1.Values.Add("5679");
// Use AddOrQuery to build an Or subquery between two different
attributeIDs (CLASS="E-MAIL" OR TYPE="MIME")
IManOrQuery oq = andQuery.AddOrQuery();
IManFieldQuery oqClass = _
oq.AddFieldQuery(imProfileAttributeID.imProfileClass);
oqClass.Values.Add("E-MAIL");
IManFieldQuery oqType = _
oq.AddFieldQuery(imProfileAttributeID.imProfileType);
oqType.Values.Add("MIME");
try
{
string strResults= string.Empty;
int ct=0;
// Pass in the ManAndQuery parameter to run the search
IManDocuments results = _
(IManDocuments)sess.WorkArea.SearchDocumentsEx(dblist, andQuery);
...
}
btw thanks for your help sofar
Marco
jny
That example code shows that it is intended to search by more than one profile field/attributeID; whereas, in your case, it seems to me you're trying to search by a single attributeID. So, I'm afraid I still fail to see your point or what you're trying to accomplish.
Would you explain in another way, perhaps in a higher-level, putting aside your current idea of a search criteria, to describe what your objective is?
(Btw, this issue is also opened with Devsupport and we have not received a response from you there.)
Thanks.
Marco_at_NL
I just resended my response to devsupport.
Thanks
Marco
jny
Please, again, note that the code example from the SDK application is a search query that is joined by more than one attribute: Author AND Class AND (Client OR TYPE). This is not, to me, anything comparable to what you appear to have set out to do, which is: Author AND "??". This is not a complex query.
If you need further help, then you really need to let us know, either here in Forum or DevSupport, what is it that you're trying to search for at a higher level -- putting aside the search query you have in mind. For instance, "I'm trying to search by AUTHOR field only, and searching for specifically the names, "GUEST", "JSMITH", "MJONES".