Question : Dynamically Create a Sharepoint folder from an Infopath Form

Hi

I'm writing a enquiry entry system in sharepoint 2010 and using infopath 2010 web forms to submit the data.

Once the web form is complete and the submit button is pressed i need a subfolder to be created and named using two variables from the form (ie [enquryref].[jobno]) and a copy of the form saved in the root folder.

I've been advised to create a custom web service to achieve this but i'm unsure how to call the code from the infopath form.

The web service code i have so far is as follows,

Can anyone assist please?  I'm new to this type of development.

thanks in advance


1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using System.Net;
using System.Xml;
using mro.s_rm_sp;


namespace mro
{
    /// <summary>
    /// Summary description for willis
    /// </summary>
    [WebService(Namespace = "http://s-rm-sp/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class willis : System.Web.Services.WebService
    {
 private void CreateFolder(string listName, string rootSubFolderName, string newFolderName)
        {
            mro.s_rm_sp.Lists listService = new mro.s_rm_sp.Lists();
            listService.Credentials = System.Net.CredentialCache.DefaultCredentials;

            //Correct invalid characters 
            newFolderName = newFolderName.Replace(":", "_");
            string rootFolder = rootSubFolderName.Length > 0 ? string.Format("/{0}/{1}", listName, rootSubFolderName) : listName;
            string xmlCommand = string.Format("<Method ID='1' Cmd='New'><Field Name='ID'>New</Field><Field Name='FSObjType'>1</Field><Field Name='BaseName'>{1}</Field></Method>", rootFolder, newFolderName);
            XmlDocument doc = new XmlDocument();
            System.Xml.XmlElement batchNode = doc.CreateElement("Batch");
            batchNode.SetAttribute("OnError", "Continue");
            //Insert / to front as it is required by web service. 
            if (!rootFolder.StartsWith("/"))
                rootFolder = string.Format("/{0}", rootFolder);

            batchNode.SetAttribute("RootFolder", rootFolder);
            batchNode.InnerXml = xmlCommand;
            XmlNode resultNode = listService.UpdateListItems(listName, batchNode);
            if ((resultNode != null) && (resultNode.FirstChild.FirstChild.InnerText == FOLDER_EXISTS) || (resultNode.FirstChild.FirstChild.InnerText == SUCCESS))
            {
                // success
            }
            else
            {
                //failure
                throw new Exception("Create new folder failed for: " + newFolderName + ". Error Details: " + resultNode.OuterXml);
            }
        }
    }
}

Answer : Dynamically Create a Sharepoint folder from an Infopath Form

The "KPI list" should be found when you want to create a list in the "Custom Lists" area.

Here is the link to the MS help site where you will find some useful information about KPIs:
http://office.microsoft.com/en-us/sharepoint-server-help/create-and-publish-key-performance-indicators-kpis-HA010080027.aspx

hope this helps
Random Solutions  
 
programming4us programming4us