I have a task where I need to perform the following tasks;

  1. Create a folder in SharePoint Titled on a company name
  2. Update a list item URL field with the URL of the folder from step 1, where the company name matches

I am trying to do this in one script. I have managed to do step one but I am really struggling with transitioning to step 2. How would I go about getting the URL from the folder I have just created and update the list item in another list?

This is what I have (Thanks in advance);

static void Main(string[] args)
            // Metadata for new Folder
            string collection = "BVI";
            string siteUrl = string.Concat("http://opm.group.local/sites", "/", collection);
            string library = "Library";
            string title = "Title";
            string refCode = "RefCode";
            string administrator = "Administrator";
            string manager = "Manager";
            string clientDirector = "ClientDirector";
            string administratorGroup = "AdminGroup";

            using (ClientContext ctx = new ClientContext(siteUrl))
                // Get Library by Name
                List byTitle = ctx.Web.Lists.GetByTitle(library);

                // New Object of ListItemCreationInformation Class
                ListItemCreationInformation listItemCreationInformation = new ListItemCreationInformation();

                // Create folder in lib
                listItemCreationInformation.UnderlyingObjectType = FileSystemObjectType.Folder;

                // Set Internal Folder Name
                listItemCreationInformation.LeafName = title;
                ListItem listitem = byTitle.AddItem(listItemCreationInformation);

                // Set Folder Name
                listitem["Title"] = refCode;

                // Set Folder Metadata
                listitem["EntityNumber"] = refCode; 
                listitem["RefCode"] = refCode; 
                listitem["Administrator"] = administrator;
                listitem["Manager"] = manager;
                listitem["ClientDirector"] = clientDirector;
                listitem["AdministratorGroup"] = administratorGroup;



Your Answer

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

Browse other questions tagged or ask your own question.