Update new field with existing data programmatically
-
I have a requirement to write a code that update an existing lookup field. We are running sharepoint 2010. We have a content type, which is used throughout all the sites. The content type has a field called Product, which is a lookup field for all the products we have. The field also contains subproducts. For example, a product by name PR1000 has a subproduct PR1010 all in the same drop down menu. Now we want to change this grouping and separate them based on product and subproduct. I have created new field called Parent Product (PP) and Child Product(CP). I would like to programmatically update the Parent Product field with Product and Child PRoduct field with child product if any. So here is how it works; if an existing item or document has product PR1010, I would to update PP with PR1000 and CP with 1010. The problem I am having in order to start this project is the product field is part of every document library and lists and there are 1000s of items with data for product. Please help with ideas or suggestions. I am thinking of a feature event receiver, which when activated will automatically update every item with product field not empty. Thanks for your help in advance.
-
I have a requirement to write a code that update an existing lookup field. We are running sharepoint 2010. We have a content type, which is used throughout all the sites. The content type has a field called Product, which is a lookup field for all the products we have. The field also contains subproducts. For example, a product by name PR1000 has a subproduct PR1010 all in the same drop down menu. Now we want to change this grouping and separate them based on product and subproduct. I have created new field called Parent Product (PP) and Child Product(CP). I would like to programmatically update the Parent Product field with Product and Child PRoduct field with child product if any. So here is how it works; if an existing item or document has product PR1010, I would to update PP with PR1000 and CP with 1010. The problem I am having in order to start this project is the product field is part of every document library and lists and there are 1000s of items with data for product. Please help with ideas or suggestions. I am thinking of a feature event receiver, which when activated will automatically update every item with product field not empty. Thanks for your help in advance.
Do you have correct setup contenttypes? Is the Product field part of such contenttype? Then I would start with input WSC to check. 1. Read all Lists 2. go to every list check if this / these contenttype(s) exists 3. get all affected items with a query. Run the code for every item It's no big problem I think it just might take a little bit to run through all lists from one WSC and of course do this for every WSC you have to check.
SharePoint Consultant and Developer at acocon Author of Primary ROleplaying SysTem I'm the ninth in a row of seven!
-
I have a requirement to write a code that update an existing lookup field. We are running sharepoint 2010. We have a content type, which is used throughout all the sites. The content type has a field called Product, which is a lookup field for all the products we have. The field also contains subproducts. For example, a product by name PR1000 has a subproduct PR1010 all in the same drop down menu. Now we want to change this grouping and separate them based on product and subproduct. I have created new field called Parent Product (PP) and Child Product(CP). I would like to programmatically update the Parent Product field with Product and Child PRoduct field with child product if any. So here is how it works; if an existing item or document has product PR1010, I would to update PP with PR1000 and CP with 1010. The problem I am having in order to start this project is the product field is part of every document library and lists and there are 1000s of items with data for product. Please help with ideas or suggestions. I am thinking of a feature event receiver, which when activated will automatically update every item with product field not empty. Thanks for your help in advance.
Please go ahead with termstore and term set creation for your requirement. Once term store is created, add it to content type Column(s) you have. This way maintenance becomes easy.