0

I have just imported an excel table to SharePoint List.

The "Title" field is text by default and I have values "Mr", "Mrs", "Ms", ... in it.

I need "Title" field to be choice instead.

I know that I can't just change the "Title" field type as for other fields.

If I then create another field "TitleChoice" with all my choices, is there an easy way to update all existing items, like:

item["TitleChoice"] = item["Title"]

I have more than 5000 items in my List.

Thanks!

2

Not sure if below are easier way but you can try below.

  1. Write temporary JSOM code to udpate list items.
  2. Write workflow to update all the items.
  3. Write .net utility using managed client object model to update item.

Sample code for 3rd option, though it would take some time in updating but it should work

static void Main()
        {
            string siteUrl = "http://MyServer/sites/MySiteCollection";

            ClientContext clientContext = new ClientContext(siteUrl);
            SP.List oList = clientContext.Web.Lists.GetByTitle("Announcements");

            CamlQuery camlQuery = new CamlQuery();
            camlQuery.ViewXml = "<View><Query><Where><Geq><FieldRef Name='ID'/>" +
                "<Value Type='Number'>0</Value></Geq></Where></Query><RowLimit>100</RowLimit></View>";
            ListItemCollection collListItem = oList.GetItems(camlQuery);

            clientContext.Load(collListItem);

            clientContext.ExecuteQuery();

            foreach (ListItem oListItem in collListItem)
            {
                ListItem oListItem = oList.Items.GetById(oListItem.Id);
                oListItem["TitleChoice"] = oListItem["Title"];
                oListItem.Update();
                clientContext.ExecuteQuery(); 

            }
        }
  • I wrote a temporary REST API code, similar to your 1st suggestion. Did all the job, even though it took around 5 minutes for 9k items and IE was not responding the whole time :)) – Gintas K Nov 30 '16 at 11:24
  • yes IE does that...that is why custom .net utility was recommended option... – Siddharth Vaghasia Nov 30 '16 at 11:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.