Logo 
Search:

Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

How to programmatically query a lookup type column in doc library?

  Asked By: Edmond    Date: May 05    Category: Sharepoint    Views: 1523

I have a column that is checkbox multiple choice that works
I go out to content type and get value array for column Product

SPSite siteCollection = new SPSite(SPContext.Current.Site.ID);
SPWebCollection collWebsites = siteCollection.AllWebs;
foreach (SPWeb oWebsite in collWebsites)
{
if (oWebsite.Url == "https://tsbusis.tams.com")
{
SPFieldCollection collFields =
oWebsite.ContentTypes["CTDoc"].Fields;
XmlDocument doc = new XmlDocument();
doc.LoadXml(collFields.SchemaXml);
for (int intIndex = 0; intIndex < collFields.Count;
intIndex++)
{
if
(collFields[intIndex].InternalName.EndsWith("Product"))
{
strProduct =
doc.FirstChild.ChildNodes.Item(intIndex).InnerXml.ToString();
strProduct = strProduct.Replace("<CHOICES>",
"").Replace("</CHOICES>", "").Replace("<CHOICE>", "");
strProduct = strProduct.Replace("</CHOICE>",
";");
ViewState["aProducts"] =
strProduct.Split(';');
}


I populate a drop down list for the users on the search page with the
products they select one and I pass it

string queryText = "select url,Filename,
HitHighlightedSummary,Product,DocSet, RevisedDate, Abstract, Path, Rank from
scope() WHERE \"scope\"='CT Library' and Product='CT'";

this works fine

I have a column that is a lookup column. It gets values from a list with
100 items. The library has rows usually only 25 say of the possible 100 and
I want to populate the user drop down list only with items that are actually
used. So I go out to the document library list and get a list of vaules from
the column. These values are an array, the id and the value. I only add the
value to the drop down list. This works for a row with only a single value
but for a row with more than one lookup value it does not work

the only search syntax that works is
metacolumn = 'value'
I cannot use a wildcard or a contains.

How can I get the value used by a list item in a lookup column. and use it
for a select from scope statement, I have customized advanced search page.

Share: 

 

No Answers Found. Be the First, To Post Answer.

 




Tagged: