0
votes

I have two Sharepoint lists - ListA and ListB. ListA has columns productName, productType. ProductType is made of choices (TypeA, TypeB, TypeC). Each product must belong to only one type. He gives Product Name and ProductType(from Selection) during adding products to ListA. ListB has columns RequestName, RequestDate, ProductName. ProductName is simply lookup to the ListA.

In ListB while adding new item,I first want to select productType and then display products of this type only. But, I couldn't find any ways to do this. Is there any way to do this, even programmatically.

OR alternatively, actually I don't need productType information in ListB. I am making workflow that uses ListB and that starts automatically when I add requests to ListB (he selects productName, and give RequestName and RequestDate). Then, in workflow, I have to check if the productName is of typeA or typeB or typeC, since I need this productType information to make some decisions in Workflow. Is there any way to get productType information from only productName using ListA and ListB.

Since this productName is unique, in Sql, it would be something like this

  select productType from ListA where productName="selectedProduct" 

but I have no clue if I can do some query in Lists in SP and get this result, store it in variable and use this later on.

Thanks


Note : For someone interested in cascading lookups in Sharepoint using Infopath forms, look here http://blog.libinuko.com/2010/07/21/sharepoint-2010-how-to-create-cascading-lookup-field/

2

2 Answers

1
votes

If you have medium to advanced programming skills, you can achieve this by creating a custom field type. The basics are outlined in this article: http://msdn.microsoft.com/en-us/library/gg132914.aspx

Basically, a custom field type is made of:

  • an xml file defining the field name, properties and some other settings
  • a class inheriting from SPField (this is the actual field)
  • a field control (this is what you see on the new/edit listitem forms)
  • a field editor control (this is what you see when you create or modify the field, where you set the field properties)
  • a field value class

Some of those components are optional. In your case, you'll probably want to create a field that inherits from SPFieldLookup and create a custom field control and a custom field editor control. There's no need for a custom field value class, since you'll use the SPFieldLookupValue class.

A quick search on Google (or the search engine of your choice) can give you lots of detailed information and tutorials about the art of creating custom field types.

0
votes

I would suggest using one of the cascading lookup fields available as 3rd party products, such as this one (i admit, this one is made by our company). Then you can have your product name column filtered by the Product Type column. No custom development required, you will just need to make some small changes to your lists (such as create a Product Types list and look it up, instead of using a choice column)