Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Simple one parameter search
abRussB
I have a lot of examples on complex searches, but how do I do one with one simple parameter?
Do I have to use IManFieldQuery?
All it should involve is comparing imProfileAttributeID.imProfileDocNum and my textfield txt_DocNum.Text
Find more posts tagged with
Comments
jny
You don't need to use the IManField query if you're not doing complex searching.
What do you mean by comparing the docnum attribute with user-entered doc num?
abRussB
I should have mentioned this was for the WorkSite SDK. I am working on an asp.net web application.
"You don't need to use the IManField query if you're not doing complex searching."
What would you use then?
jny
If you could explain to me the question I've previously asked, then I can better help you.
abRussB
Maybe this will help.
The query below works, but what I want to do is simply use the first three lines of this. When I try to use just the first three lines I get: [WorkArea ][SearchDocumentsEx ]Search parameter invalid
Dim myQuery As IManAndQuery = New ManAndQueryClass()
Dim myQueryField As IManFieldQuery = myQuery.AddFieldQuery(imProfileAttributeID.imProfileDocNum)
myQueryField.Values.Add(2176361)
Dim aq As IManAndQuery = myQuery.AddAndQuery()
Dim andQueryField As IManFieldQuery = myQuery.AddFieldQuery(imProfileAttributeID.imProfileAuthor)
andQueryField.Values.Add(txt_UserID.Text)
Dim oq As IManOrQuery = myQuery.AddOrQuery()
Dim aqC2 As IManFieldQuery = aq.AddFieldQuery(imProfileAttributeID.imProfileCustom2)
aqC2.Values.Add("030000")
Dim oqClass As IManFieldQuery = oq.AddFieldQuery(imProfileAttributeID.imProfileClass)
oqClass.Values.Add("E-MAIL")
Dim oqType As IManFieldQuery = oq.AddFieldQuery(imProfileAttributeID.imProfileType)
oqType.Values.Add("MIME")
jny
The query you've built does not look correct. Would you let me know what is your search criteria, e.g. (DOCNUM=2176361 AND AUTHOR=[txt_UserID.Text]) OR (CUSTOM2="030000" OR CLASS="E-MAIL" OR TYPE="MIME")?
Also, if you haven't already looked into it, this link will take you to the technote that has complex searching reference and code examples to building various complex queries:
https://support.interwoven.com/kb/kb_show_article2.asp?ArticleID=53221
abRussB
All I want to do is a search that says find a document where the docnum = 12345
All of the search examples use and/or type queries, but I don't need that in this case. I would think this should be rather simple, but I can't find an answer in any of the documentation.
jny
If that's all you wanted to do, then you've been looking at the wrong place for reference and example code. The SDK comes with a reference manual "COM Reference Manual for WorkSite.pdf" which explains the different types of document search methods.
If you have said that from the very beginning, I would have told you this:
There are two ways to search for a document by its document number:
(1) Use the SearchDocuments (IManDatabase) Method and pass in the searchparameters argument that has the IManProfileSearchParameters populated with one search parameter, e.g.,
IManProfileSearchParameters.Add imProfileDocNum, "12345"
(2) Call the GetDocument (IManDatabase) Method and pass in the docnum and version to the method's arguments, e.g.,
IManDatabase.GetDocument(12345, 1)
abRussB
I ended up doing it like this:
Dim myparams As IManWorkspaceSearchParameters
Dim myprofs As IManProfileSearchParameters
Dim results As IManContents
Dim objMessage As String
db = sess.Databases.ItemByName("myDatabase")
myparams = dms.CreateWorkspaceSearchParameters()
myprofs = dms.CreateProfileSearchParameters()
myparams.Add(imProfileAttributeID.imProfileDocNum, txt_DocNum.Text)
myprofs.Add(imProfileAttributeID.imProfileDocNum, txt_DocNum.Text)
results = db.SearchDocuments(myprofs, False)
jny
I still don't have a concise understanding of what you are ultimately trying to accomplish.
I thought I finally understood it when you said, at last, that you would like to search for a document by its docnum --
"All I want to do is a search that says find a document where the docnum = 12345"
-- and that was why I gave you the two approaches in my previous response.
Now, you are showing me code that searches for a document (by the docnum) in the workspace profile search parameters as well as the document profile search parameters. The former, searching docnum via IManWorkspaceSearchParameters, does not make sense to me at all.
What are you trying to do? Are you attempting to perform a searchwithin, i.e., searching for a document from within a container, namely a workspace or a folder?? Or something else???
Sorry, I'm at a loss by the lack of concise information.
abRussB
The code I posted was actually from someone at Interwoven and it returns the doc, but I think your method would probably be better I just couldn't figure out the details.
I'm trying to implement your suggestion as follows:
Dim results As IManContents
db = sess.Databases.ItemByName("Phoenix")
Dim profparams As IManProfileSearchParameters
profparams.Add(imProfileAttributeID.imProfileDocNum, txt_DocNum.Text)
results = db.SearchDocuments(profparams, False)
In my .Net app I am getting the error Object reference not set to an instance of an object on this:
profparams.Add(imProfileAttributeID.imProfileDocNum, txt_DocNum.Text)
jny
The error occurred because you hadn't created an instance of the IManProfileSearchParameters Collection Object yet. To do that, you would need to call the IManDMS.CreateProfileSearchParameters Method. Like so:
' Assuming dms is a handle to the valid IManDMS Object
Dim profparams As IManProfileSearchParameters = dms.CreateProfileSearchParameters()
If you're merely querying for the document object by its docnum, it's more efficient to call the GetDocument (IManDatabase) Method and be done with it:
' Assuming sess is a handle to the valid IManSession Object
db = sess.Databases.ItemByName("myDatabase")
Dim doc As IManDocument = db.GetDocument(12345, 1)
abRussB
Thank you very much for your help. It's working great!
If I may pose one last question, we are currently testing on one named database with plans to go to three. What would I do when we eventually have three named db's?
For instance, now I am using this:
db = sess.Databases.ItemByName("Phoenix")
What would this be if I had Phoenix, Phoenix2, Phoenix3 to search?
jny
You would need to call the same SearchDocuments Method off of the IManSession Object.
Dim oDMS As New ManDMS
Dim oSess As IManSession = oDMS.Sessions.Add("SERVER_NAME")
oSess.TrustedLogin
Dim dblist As New ManStrings
Dim i As Integer
For i = 1 To oSess.Databases.Count
dblist.Add oSess.Databases.ItemByIndex(i).Name
Next i
Dim params As IManProfileSearchParameters = oDMS.CreateProfileSearchParameters
params.Add imProfileDocNum, "12345"
Dim results As IManDocuments = oSess.SearchDocuments(dblist, params, True)