Monday 8 October 2012

Make Document Set using infopath code in sharepoint 2010.

1.First create one Document Library and go to library sittings.
2.Open Advanced setting, then click "Yes" Allow management of centent types.
3.then Add from existing site content types , select Document Set.
4.Go to Infopath 2010, add one check box write code one change event in check box.

            XPathNavigator myRootNode = MainDataSource.CreateNavigator();
             myRootNode.SelectSingleNode(" /my:myFields/my:field4", NamespaceManager).SetValue("rintu");
            try
            {
               
                SPWeb web = SPContext.Current.Web;
                myRootNode.SelectSingleNode(" /my:myFields/my:field4", NamespaceManager).SetValue(web.Url.ToString());
                SPList list = web.Lists["BriefingDoc"];
                string sguid = System.Guid.NewGuid().ToString();
                web.AllowUnsafeUpdates = true;
                string sDocsetName = string.Empty;
                sDocsetName = "Document Set";
                DocumentSet ds = DocumentSet.Create(list.RootFolder, sguid, list.ContentTypes[sDocsetName].Id, null, true);
                web.AllowUnsafeUpdates = false;
                string DocUrl = ds.WelcomePageUrl.Replace("Document Set", "Document%20Set");
                myRootNode.SelectSingleNode("/my:myFields/my:field2/@my:field3", NamespaceManager).SetValue(DocUrl);

            }
            catch (Exception ex)
            {
                myRootNode.SelectSingleNode("/my:myFields/my:DatadeTérminoMessage", NamespaceManager).SetValue(ex.Message);
            }
            }

5.see that one hyper link is created, click that and upload the documents.

2 comments:

  1. Hello Rintu,

    Can you please give a little bit of background on when to use your tip?

    I am looking for as solution regarding docset that has infopath form/s inside of it, not sure if this solution applies to my context.

    Any help is highly appreciated.


    Regards,
    CM

    ReplyDelete
  2. Hello,

    InfoPath have one draw back regarding attachments, only 5 MB is maximun storage limit with in the InfoPath form.
    But in our requirement, client want to upload more than 5 MB files, some we are use Doucument Set in sharepoint library to storage the files.
    Simple we take one check box with event code, we generate a dynamic url to store the files.

    Please let us know if you need any other help or if you have any issues.

    Thanks
    Rintu

    ReplyDelete