Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8626249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:58:47+00:00 2026-06-12T07:58:47+00:00

In the current scenario I am trying to copy a document set from one

  • 0

In the current scenario I am trying to copy a document set from one library to another, the thing is I cant use DocumentSet.Import because I only need the docset properties and not the contents.

The exception is thrown in the System.Update of this code.

private void CopyAgendaPointToRootSite(SPListItem agendaPointItem, string oldReasonReturned)
        {

            try
            {
                if (agendaPointItem != null)
                {
                    SPWeb currentSite = agendaPointItem.ParentList.ParentWeb;
                    SPSecurity.RunWithElevatedPrivileges(delegate()
                    {
                        using (SPSite site = new SPSite(currentSite.Site.RootWeb.Url))
                        {
                            using (SPWeb elevatedTargetWeb = site.OpenWeb())
                            {
                                SPList targetList = GetAgendaPointProposedTargetLibrary(agendaPointItem, elevatedTargetWeb);
                                SPDocumentLibrary targetDocumentLibrary = (SPDocumentLibrary)targetList;

                                SPContentTypeId targetCTId = targetList.ContentTypes.BestMatch(new SPContentTypeId(MeetingsCommon.Constants.CONTENTTYPES_AGENDAPOINTPROPOSED_ID));
                                DocumentSet documentSet = DocumentSet.GetDocumentSet(agendaPointItem.Folder);
                                if (documentSet != null)
                                {
                                    string strAgendaPointTitle = agendaPointItem[MeetingsCommon.Constants.FIELDS_AGENDAPOINTTITLENL_NAME] +
                                        " / " + agendaPointItem[MeetingsCommon.Constants.FIELDS_AGENDAPOINTTITLEFR_NAME];

                                    SPListItemCollection colProposedItems = FindAgendaPointProposedItem((SPDocumentLibrary)targetList, documentSet.Item.Name);
                                    if (colProposedItems.Count > 0)
                                        throw new Exception(string.Format(HelperFunctions.GetResourceString(
                                            MeetingsCommon.Constants.RESOURCES_FILE_NAME,
                                            "Message_AgendaPointsEvents_ERROR_DocumentSetAlreadyExistsInRootSite2"), strAgendaPointTitle));



                                    using (DisableItemEventScope scope = new DisableItemEventScope())
                                    {
                                        DocumentSet docSetCreated = DocumentSet.Create(targetList.RootFolder, agendaPointItem.Name, targetCTId, new Hashtable(), true);
                                        SPListItem listItem = docSetCreated.Item;

                                        foreach (SPField field in agendaPointItem.Fields)
                                        {
                                            if (!field.ReadOnlyField && field.InternalName != "Attachments" &&      field.InternalName  != "TaxCatchAll")   
                                            {
                                                if (agendaPointItem[field.Id] != null)
                                                {
                                                    string targetFieldInternalName = field.InternalName;
                                                    if (listItem.Fields.ContainsField(field.InternalName))
                                                    {
                                                        listItem[targetFieldInternalName] = agendaPointItem[field.InternalName];
                                                    }
                                                }
                                            }
                                        }

                                        string reasonreturned = "---- <br/>Reason returned: " + currentSite.Title + " Rejected. " + "<br/> "
                                                                         + agendaPointItem.GetTaxonomyFieldValueByLanguage(site, MeetingsCommon.Constants.FIELDS_AGENDAPOINTDECISION_NAME, 1036) + "<br/> "
                                                                         + agendaPointItem.GetTaxonomyFieldValueByLanguage(site, MeetingsCommon.Constants.FIELDS_AGENDAPOINTDECISION_NAME, 1043) + "<br/> "
                                                                         + agendaPointItem.GetFieldValue(MeetingsCommon.Constants.FIELDS_AGENDAPOINTDECISIONCOMMENTSNL_NAME)
                                                                         + agendaPointItem.GetFieldValue(MeetingsCommon.Constants.FIELDS_AGENDAPOINTDECISIONCOMMENTSFR_NAME)
                                                                         + agendaPointItem[MeetingsCommon.Constants.FIELDS_AGENDAPOINTSREASONRETURNED_NAME] + "<br/>----";

                                        SPFieldUrlValue value = new SPFieldUrlValue();
                                        value.Description = currentSite.Title;
                                        value.Url = currentSite.Url;                                      
                                        listItem[MeetingsCommon.Constants.FIELDS_AGENDAPOINTPOSTPONEDFROM_NAME] = value;
                                        listItem[MeetingsCommon.Constants.FIELDS_MEETING_NAME] = null;
                                        listItem[MeetingsCommon.Constants.FIELDS_AGENDAPOINTSTATUS_NAME] = null;
                                        listItem[MeetingsCommon.Constants.FIELDS_AGENDAPOINTSREASONRETURNED_NAME] = reasonreturned;

                                        //Clear the category and status field
                                        listItem.ClearTaxonomyFieldValue(MeetingsCommon.Constants.FIELDS_AGENDAPOINTSTATUS_NAME);
                                        listItem.ClearTaxonomyFieldValue(MeetingsCommon.Constants.FIELDS_AGENDAPOINTDECISION_NAME);
                                        listItem.SystemUpdate(false);
                                    }                                           
                                }
                            }
                        }
                    });
                }
            }
            catch (Exception ex)
            {

                throw;
            }

        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T07:58:48+00:00Added an answer on June 12, 2026 at 7:58 am

    I fixed it doing the following

     DocumentSet docSetCreated = DocumentSet.Create(targetList.RootFolder, agendaPointItem.Name, targetCTId, new Hashtable(), true);
                                            int  listItemId = docSetCreated.Item.ID;
                                            SPListItem listItem = targetList.GetItemById(listItemId);
    

    apparently after the documentset is created, I cant use the listitem of that object anymore, I need to get a new one

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The current issue im facing is comes from the following scenario. I have a
The scenario: Trying to restore from a bacpac taken from SQL Azure. Either to
I am migrating our company SCM from SVN to mercurial. The current scenario is
I was trying to get the information from my table Paper_Details based on current
This is my current scenario: I have checked in my grails app code +
We have a scenario where some .NET code is attempting to access the current
Current situation: Ubuntu 8.04 server edition (live server) Postgresql 8.3.7 (from standard repositories) Postgis
Current scenario, I launch a process that forks, and after a while it aborts().
I'm trying to implement unit tests in my current project. After that I'll start
OK, the scenario is: i`m trying to keep 3 nested forms on the same

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.