Thứ Năm, 30 tháng 9, 2010

jQuery for SharePoint Web Services

The “core” of the jQuery Library for SharePoint Web Services is the $().SPServices function, which allows you to simply call each Web Service operation.

The table below shows the Web Services currently available in the library and where they work, along with links to the MSDN documentation:

Web Service WSS 3.0 MOSS MSDN Documentation
Alerts Alerts Web Service
Authentication Authentication Web Service
Forms Forms Web Service
Lists Lists Web Service
Permissions Permissions Web Service
Users and Groups Users and Groups Web Service
Versions Versions Web Service
Views Views Web Service
WebPartPages Web Part Pages Web Service
Webs Webs Web Service
PublishedLinksService   PublishedLinksService Web Service
Search   Search Web Service
UserProfileService   User Profile Web Service
Workflow   Workflow Web Service
 
Calling the Library

To set things up to use the jQuery Library for SharePoint Web Services, you’ll need to add references to it and the core jQuery library in the right context for what you are trying to accomplish.

<script src="/TimeSheet/jQuery%20Libraries/jquery-1.4.2.min.js" type="text/javascript"></script>
<script src="/TimeSheet/jQuery%20Libraries/jquery.SPServices-0.5.6.min.js" type="text/javascript"></script>


What all this adds up to is that you can use the jQuery Library for SharePoint Web Services to call any of the Web Service operations it wraps as simply as this:



   1: $().SPServices({
   2:    operation:  "GetList",
   3:    listName:  "Project",
   4:    completefunc: function  (xData, Status) {
   5:      ...do something...
   6:    }
   7: });

The Results

When you make one of these calls, you get back XML, just as you’ve passed XML into it. As I was building the library, I found that I very often wanted to see what was in that XML in an easy to read format, so I built the $().SPServices.SPDebugXMLHttpResult function. If you’re comfortable with XML and debugging tools, you may never need this function, but I find it useful. If you wanted to use it in the above example, replace the completefunc with this:



   1: completefunc: function (xData, Status) {
   2:    var out =  $().SPServices.SPDebugXMLHttpResult({
   3:      node:  xData.responseXML
   4:    });
   5:    $(divId).html("").append("<b>This  is the output from the GetList operation:</b>" + out);
   6: }

where divId is the ID for a DIV on the calling page where you’d like to place the results. The output from the $().SPServices.SPDebugXMLHttpResult function for GetList will look something like this excerpt:


 

A21319952F68E79E_946_0[1]A21319952F68E79E_946_1[1]

On the other hand, if you’d like to work with the output, you’d probably do something like this:



   1: $().SPServices({
   2:    operation:  "GetList",
   3:    async: false,
   4:    webURL: opt.webURL,
   5:    listName:  opt.listName,
   6:    completefunc:  function(xData, Status) {
   7:      $(xData.responseXML).find("Field").each(function()  {
   8:        if($(this).attr("StaticName")  == opt.columnStaticName) displayName = $(this).attr("DisplayName");
   9:      });
  10:    }
  11: });

This example comes from the $().SPServices.SPGetDisplayFromStatic function. In the completefunc, I find all of the Field elements, iterate through them until I find the one I’m looking for, then grab the DisplayName attribute to return.


Source Reference

Thứ Tư, 22 tháng 9, 2010

Load control template file /_controltemplates/TaxonomyPicker.ascx failed: SharePoint 2010

Problem:
Numerous errors in the event log of a SharePoint 2010 server with the following error event descriptions:

Load control template file /_controltemplates/TaxonomyPicker.ascx failed: Could not load type 'Microsoft.SharePoint.Portal.WebControls.TaxonomyPicker' from assembly 'Microsoft.SharePoint.Portal, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'.

and

Load control template file /_controltemplates/ScenarioNavigation.ascx failed: The 'wssuc:ButtonSection' tag has already been registered.

Fix 1:
Locate the file “TaxonomyPicker.ascx” in the Controltemplates directory of the 14 Hive, search for the following line

<%@ Control className="TaxonomyPickerControl" Language="C#" Inherits="Microsoft.SharePoint.Portal.WebControls.TaxonomyPicker&#44;Microsoft.SharePoint.Portal, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>


and replace ‘&#44;’ with ‘,’.

The correct line should look like


<%@ Control className="TaxonomyPickerControl" Language="C#" Inherits="Microsoft.SharePoint.Portal.WebControls.TaxonomyPicker,Microsoft.SharePoint.Portal, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>


Fix 2:
Locate the file “ScenarioNavigation.ascx” in the Controltemplates directory of the 14 Hive, search for a duplicate line of


<%@ Register TagPrefix="wssuc" TagName="ButtonSection" Src="/_controltemplates/ButtonSection.ascx" %>


and delete the second one.

Update:

The second problem seems to be fixed in the RTM version. The “TaxonomyPicker.ascx”-Problem still persists.

Update2:

Fix 1 (“TaxonomyPicker.ascx”) doesn’t apply to the RTM Version anymore as the “TaxonomyPicker” Class seems to be obsolete.
If you want to fix this error simply rename the “TaxonomyPicker.ascx” to something like “TaxonomyPicker.ascxBACKUP” to prevent recompilation by the CLI and the error is gone.

Reference





Comments




Quang Nguyen Ba - 9/22/2010 11:15:55 AM
Infact TaxonomyPicker is no longer in use: http://todd-carter.com/post/2010/05/03/Help-Wanted-Taxonomy-Picker.aspx

Thứ Ba, 21 tháng 9, 2010

SPServices: Cascading Drop-Down List in SharePoint 2010 List using jQuery

1. Create Cities custom list:

2. Create Districts Custom list: with City lookup column

3. Create Ward custom list: with District lookup column

4. Create Addresses list: with City, District, Ward lookup columns

Using following scripts in the NewForm.aspx of Addresses

<script src="/TimeSheet/jQuery%20Libraries/jquery-1.4.2.min.js" type="text/javascript"></script>
<script src="/TimeSheet/jQuery%20Libraries/jquery.SPServices-0.5.4.min.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
        $(document).ready(function() {
            $().SPServices.SPCascadeDropdowns({
                relationshipList: "Districts",
                relationshipListParentColumn: "City",
                relationshipListChildColumn: "Title",
                relationshipListSortColumn: "ID",
                parentColumn: "City",
                childColumn: "District",
                promptText: "Choose District...",
                debug: true
            });
 
            $().SPServices.SPCascadeDropdowns({
                relationshipList: "Ward",
                relationshipListParentColumn: "District",
                relationshipListChildColumn: "Title",
                relationshipListSortColumn: "ID",
                parentColumn: "District",
                childColumn: "Ward",
                promptText: "Choose Ward...",
                debug: true
            });
        });
</script>

Hope this help!

SPServices: Using jQuery to auto fill current user information in SharePoint 2010

Using following script in your page by SharePoint Designer or Content Editor WP

<script language="javascript" src="/TimeSheet/jQuery%20Libraries/jquery-1.4.2.min.js" type="text/javascript"></script>
<script language="javascript" src="/TimeSheet/jQuery%20Libraries/jquery.SPServices-0.5.4.min.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function() {
    var userDepartment = $().SPServices.SPGetCurrentUser({
        fieldName: "Department"
    });
    $("input[Title='Department']").val(userDepartment);    
});
</script>

In this script, we auto fill Department textbox by department of current user.


Reference

Thứ Sáu, 17 tháng 9, 2010

Configure Excel Calculation Services on SharePoint 2010

Sometime we can’t open excel file in SharePoint pages. Looking event viewer you see “There was an error in communicating with Excel Calculation Services”. If this is happened, following steps:

- Open IIS then go to “SharePoint Web Services Root” application pool

- Verify that Identity property of this application pool is setting to the SharePoint farm account like this (It’s must be DOMAIN\account.)

A21319952F68E79E_937_0[1]

Hope this help!