Submitting Date/Time with InfoPath to Web Services

 Sharepoint, Software  Comments Off on Submitting Date/Time with InfoPath to Web Services
Feb 182016
 
Share

I created an Infopath for users to request teleconference numbers.
I have two lists; Schedule and Conference List.

Schedule list had these columns: Title, Start Date, End Date, Attendees, Status, Assigned.
Conference List had these columns; Source (which will be set to Title above), Title, Phone Number, Start Date, End Date

Users get a standard request form which pulls and updates from the Schedule list.
ConReq

Admin/Operators receive workflow email that a request was placed and get an expanded form.

ConOpView

The magic is on the Assign button on the Operator section.
Rules are set to submit 5 values to the Conference List using a Web Service.

There are many good blogs that detail this process.
Reference with Screenshots: http://jaliyaudagedara.blogspot.com/2011/03/submitting-data-to-sharepoint-2010-list.html

The first step is to create an “Add List Items.xml.” This is the data to be inserted into the Conference List:

<?xml version="1.0" encoding="UTF-8"?>
<Batch OnError="Continue">
    <Method ID="1" Cmd="New">
        <Field Name="Title"></Field>
        <Field Name="Source"></Field>
        <Field Name="Number"></Field>
        <Field Name="Start"></Field>
        <Field Name="End"></Field>
    </Method>
</Batch>

The easy part is submitting text fields. Date/Time fields will fail due to invalid type errors. A common problem I’ve seen reported is that you won’t get an error on submit and no data will be posted to your list.

This the workaround for Date/Time.
Create a textbox on your form; you can hide this later.
Set the value to your original form’s time value with the following formula.

concat(YourTimeField,"Z")

TimeField

This is the important piece. The UpdateListItems call needs that “Z” appended to the Time portion.
Your modified time output will look like YYYY-MM-DDTHH:MM:00Z.

When creating your Submit to Web Service rule; add the Submit portion first. In my example the rule is “AssignNumber”.
Go to Publish and Export Source Files. You will need to edit the manifest.xsf. Find your submit rule by name and paste the following BEFORE the submitAction.

<xsf:assignmentAction targetField="xdXDocument:GetDOM(&quot;Add List Item&quot;)/Batch/Method/Field[@Name = &quot;Title&quot;]" expression="d:Title"></xsf:assignmentAction>
<xsf:assignmentAction targetField="xdXDocument:GetDOM(&quot;Add List Item&quot;)/Batch/Method/Field[@Name = &quot;Source&quot;]" expression="xdXDocument:get-DOM()/dfs:myFields/dfs:dataFields/my:SharePointListItem_RW/my:Title"></xsf:assignmentAction>
<xsf:assignmentAction targetField="xdXDocument:GetDOM(&quot;Add List Item&quot;)/Batch/Method/Field[@Name = &quot;Number&quot;]" expression="d:Number"></xsf:assignmentAction>
<xsf:assignmentAction targetField="xdXDocument:GetDOM(&quot;Add List Item&quot;)/Batch/Method/Field[@Name = &quot;Start&quot;]" expression="xdXDocument:get-DOM()/dfs:myFields/dfs:dataFields/my:SharePointListItem_RW/my:TimeStart"></xsf:assignmentAction>
<xsf:assignmentAction targetField="xdXDocument:GetDOM(&quot;Add List Item&quot;)/Batch/Method/Field[@Name = &quot;End&quot;]" expression="xdXDocument:get-DOM()/dfs:myFields/dfs:dataFields/my:SharePointListItem_RW/my:TimeEnd"></xsf:assignmentAction>

This allows you to set your Add Item CAML to push the correct values to the Web Service Submit.

From InfoPath Designer; open the manifest.xsf file. Your rules may look like this.

ConAsnRules

You can edit the value of these rules as necessary. Note that I point my Start and End Date columns to the concat fields I created earlier.

Working around SharePoint 2010’s 5,000 item view limits

 Computer, Sharepoint, Software  Comments Off on Working around SharePoint 2010’s 5,000 item view limits
Jan 082016
 
Share

Update 1/13/2016 – Changes to script. The original script hides the list view pagination. Changes marked as Pagination Fix below.

I have a SharePoint list that has exceeded the 5,000 item limit threshold. This, of course, causes a couple of views to go bonkers.
MeetMe

I indexed several list columns but the client still needs to be able to filter the entire list. I wrote some jQuery to replace that awful message shown above.

<script src="jquery-1.10.1.min.js"></script>
<script type="text/javascript">
// jQuery extension
(function($){
    $.fn.extend({
        removeByContent: function(str) {
           return this.each(function(){
                var self = $(this);
                if(self.html().indexOf(str) != -1) self.hide();
            });
        }
    });
})(jQuery);
// jQuery Show function added 1.13.2016
(function($){
    $.fn.extend({
        showByContent: function(str) {
           return this.each(function(){
                var self = $(this);
                if(self.html().indexOf(str) != -1) self.show();
            });
        }
    });
})(jQuery);
// Script to remove the error message text.
$('.ms-vb').removeByContent('This view cannot');
$('.ms-vb').removeByContent('Operations that exceed');
$('.ms-vb').removeByContent('Learn about'); 
/* Pagination Fix if needed 
$('.ms-vb').removeByContent('try selecting another view'); 
$('.ms-vb').showByContent('Next');
*/
</script>

<script type="text/javascript">
// Remove this script if list view pagination needed and add Fix lines above.
// Let's replace one of those lines with instructions for the user.
$(document).ready(function() {
     $(".ms-vb").text(function(index,text) {
      return text.replace('To view items, try selecting another view or creating a new view. If you do not have sufficient permissions to create views for this list, ask your administrator to modify the view so that it conforms to the list view threshold.','Please select a filter above.');
   });
});
</script>



Even though SharePoint is complaining in the background, selecting a filter will return results to the list web part.

MeetMe2