1

I'm having trouble figuring out a solution to a minor problem: how to get a form submission into SharePoint from our website. If we were using a Windows Server, I believe we could use InfoPath Form Services. But we're using using LAMP with Drupal 7 CMS and so there does not seem to be a solution out there after extensive searching ... I may just be using the wrong terminology during search?!

So the ultimate goal is to get a form submitted into a list, that can then kick off a workflow that ends in MS Dynamics CRM. Right now I'm just concerned with getting the form data into a SP2010 list or similar.

Each form entry should be recorded in SharePoint as an item so that it can searched for and differentiated between. That is why I believe a SharePoint list or form library would work. I am just lacking in experience with SharePoint to know the correct solution.

I'd like to know how you believe this could work, if at all. Possible solutions I've been floating around include creating a PHP form that posts to XML, then emails the XML file to a SharePoint list. But I'm lacking knowledge on the SharePoint side as to how to parse that back out into list items. So any solutions or ideas are welcomed!

2 Answers 2

2

SharePoint 2010 supports updating of list items via REST web services. The majority of examples I see are all C# related which probably will not help you, but I did run across this one that is not .Net and might serve as an example of the process.

Edit: here is the link to the related info on this from Microsoft

1
  • Thanks, those links helped. I managed to get it working a different way though, added an answer for others in this situation.
    – Paul
    Oct 1, 2013 at 18:41
2

Using an example from David Dudok de Wit as a starting point, I managed to get a PHP form to populate a SharePoint List. This is entirely extensible, but for the brevity this example includes 5 fields/columns only.

The following is all in one document, but I've broken it into two for readability.

if(isset($_POST['submit'])) {

    $title      = $_POST['title'];     
    $firstName  = $_POST['firstName'];
    $lastName   = $_POST['lastName']; 
    $age        = $_POST['age'];
    $phone      = $_POST['phone'];
}

// Requires the NuSOAP library
require_once('lib/nusoap.php');

// Authentication details
$username       = 'DOMAIN\username';
$password       = 'password';
$rowLimit       = '150';

/* A string that contains either the display name or the GUID for the list.
 * It is recommended that you use the GUID, which must be surrounded by curly
 * braces ({}).
 */
$listName = "{YOUR-GUID}";

/*
 * Example field (aka columns) names and values, that will be used in the
 * CAML query. The values are the attributes of a single list item here.
 * If the field name contains a space in SharePoint, replace it
 * here with _x0020_ (including underscores).
 */
$field1Name = "Title";
$field2Name = "forename";
$field3Name = "lastname";
$field4Name = "age";
$field5Name = "phone";

$field1Value = $title;
$field2Value = $firstName;
$field3Value = $lastName;
$field4Value = $age;
$field5Value = $phone;

/* Local path to the Lists.asmx WSDL file (localhost). You must first download
 * it manually from your SharePoint site (which should be available at
 * yoursharepointsite.com/subsite/_vti_bin/Lists.asmx?WSDL)
*/
$wsdl = "./Lists.asmx?WDSL";

// Basic authentication is normally used when using a local copy a the WSDL. Using UTF-8 to allow special characters.
$client = new nusoap_client($wsdl, true);
$client->setCredentials($username,$password);
$client->soap_defencoding='UTF-8';

// CAML query (request), add extra Fields as necessary
$xml ="
 <UpdateListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>
 <listName>$listName</listName>
 <updates>
 <Batch ListVersion='1' OnError='Continue'>
 <Method Cmd='New' ID='1'>
 <Field Name='$field1Name'>$field1Value</Field>
 <Field Name='$field2Name'>$field2Value</Field>
 <Field Name='$field3Name'>$field3Value</Field>
 <Field Name='$field4Name'>$field4Value</Field>
 <Field Name='$field5Name'>$field5Value</Field>
 </Method>
 </Batch>
 </updates>
 </UpdateListItems>
";

//Invoke the Web Service
$result = $client->call('UpdateListItems', $xml);

?>

HTML

<!DOCTYPE html>
<head>
<title>Submit Form to SharePoint List</title>
<style>
*{
    padding:0;
    margin:0;
}
body{
    text-align:center;
    font:11px "Lucida Grande",Arial,sans-serif;
}
#content{
    width:300px;
    text-align:left;
    margin:10px;
}
.formitem{
    width:100%;
    padding: 6px;
    font:11px "Lucida Grande",Arial,sans-serif;
}
</style>
</head>
<body>
    <div id="content">
        <form method="post" action="<?php echo htmlentities($_SERVER['PHP_SELF']);?>">
            <label for="name">Title: </label><input class="formitem" id="title" name="title" type="text" length="10" >
            <label for="name">First Name: </label><input class="formitem" id="firstName" name="firstName" type="text" length="25" >
            <label for="name">Last Name: </label><input class="formitem" id="lastName" name="lastName" type="text" length="25" >
            <label for="name">Age: </label><input class="formitem" id="age" name="age" type="text" length="2" >
            <label for="name">Phone: </label><input class="formitem" id="phone" name="phone" type="text" length="14" >
            <input type="hidden" name="submitted" value="1"> 
            <input type="submit" name="submit" value="Submit">
        </form>
    </div>
</body>
</html>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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