Apr
11
2009

Virtual Earth Map Control on SharePoint

James Tsai .Net SharePoint Blog Virtual Earth Map Control

Well, I finally have some free time to play with it. I know, I am two years late on this topic. But I still wanted to see how Microsoft Virtual Earth Map Control can work together with SharePoint, so I created a control that does following tasks

1. Read saved locations from SharePoint List

Read saved locations information from SharePoint list. SharePoint list stores location items with Title, Address and Description fields.

James Tsai .Net SharePoint Blog Address Book SharePoint List

Render all the locations stored in SharePoint list on Virtual Earth Map Control. Virtual earth Map Control is embedded in Content editor web part - there is no need to create a custom web part.

Display custom created panel control (VEMap Control) on Virtual Earth Map Control. It shows the pushpins, location Id and Titles - user click on the pushpin Id in panel control to see the corresponded location on map

James Tsai .Net SharePoint Blog Virtual Earth Map Control View Mode

2. Write to SharePoint List

Display Pushpin Information box when user click on pushpins – information box contains the custom created HTML with Text boxes and Edit/Save/Cancel action links.

Push changed value back to SharePoint list via SharePoint list web service (/_vti_bin/lists.asmx)

James Tsai .Net SharePoint Blog Virtual Earth Map Control Edit Mode

How to do it

Download JavaScript Files

More...

Jan
7
2009

Where do you deploy custom SharePoint web service files to? (.asmx, disco.aspx and wsdl.aspx)

Recently someone asked me to troubleshoot the problem he had with the custom web service he created.

He followed the instructions from MSDN article "Walkthrough: Creating a Custom Web Service" and generated MyWebservice.asmx, MyWebservicedisco.aspx and MyWebservicewsdl.aspx files. He also made changes to contract reference and SOAP address in both disco.aspx and wsdl.aspx to provide the necessary redirection and maintain the URL virtualization.

Web service was deployed to 12\TEMPLATE\LAYOUTS in file system and can be viewed from URL http://<site>/_layouts/MyWebservice.asmx or http://<site>/<subsite>/_layouts/MyWebservice.asmx without any issues.

"Everything looks fine except..." - he said

At this stage I knew what the problem was and his description of the problem confirmed it.

"Everything looks fine except the web service function call returns an incorrect and unexpected result"

Yes, it could be the code logic errors. But I sticked to the one obvious mistake he has made. I told him that "Only deploy your custom web service files to 12\ISAPI (\_vti_bin\) folder unless you know what you are doing"

I have seen this problem many times before from different developers, third party vendor's and IT supports. They all have their own reasons (wrong reasons) for not to deploy their custom web service files to 12\ISAPI.

Why _vti_bin folder

More...

May
20
2008

Using JavaScript to check SharePoint list item workflow status - Via Web Service call.

Microsoft Office SharePoint Server comes with many built-in Web services. And the one we are going to use here is the Workflow web service "/_vti_bin/workflow.asmx"

- GetWorkflowDataForItem operation in particular

The following JavaScript code example is fairly easy to understand.

It takes two parameters.

siteUrl - URL to your site, currentItemFileFullUrl - absolute URL to the item

And it will return you the message about item workflow status.

function CheckRunningWorkflow(siteUrl,currentItemFileFullUrl)
{
    var xh=new ActiveXObject("Microsoft.XMLHTTP");

    if (xh==null)
        return "Error: Cannot create XMLHTTP object";

    xh.Open("POST", siteUrl+"/_vti_bin/workflow.asmx", false);
    xh.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
    xh.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/sharepoint/soap/workflow/GetWorkflowDataForItem");

    var soapData='<?xml version="1.0" encoding="utf-8"?>'+
    '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"'+
    'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'+
    '<soap:Body>'+
    '<GetWorkflowDataForItem xmlns="http://schemas.microsoft.com/sharepoint/soap/workflow/"><item>'+
    currentItemFileFullUrl+
    '</item></GetWorkflowDataForItem></soap:Body></soap:Envelope>'

    xh.Send(soapData);   

    if (xh.status==200)
    {
        xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
        if (xmlDoc==null)
            return false;
        xmlDoc.async = "false";                   
        if(!xmlDoc.loadXML(xh.ResponseText))
            return false;
    var xpath = "/soap:Envelope"+
    "/soap:Body"+
    "/GetWorkflowDataForItemResponse"+
    "/GetWorkflowDataForItemResult"+
    "/WorkflowData"+
    "/ActiveWorkflowsData"+
    "/Workflows"+
    "/Workflow"

        var activeWF=xmlDoc.selectSingleNode(xpath)

    //Check if there is an active workflow for current item       
        if(activeWF != null)
        {
        //Check Workflow status code
            if(activeWF.getAttribute("InternalState") == '2')
            {
                return "Running";
            }
        else if(activeWF.getAttribute("InternalState") == '4')
            {
                return "Completed";
            }
        }
    else
    {
        reutrn "No active workflow for this item";
    }

    return "Workflow status for this item is not Running or Completed"
    }
    return "Failed to call web service";
}

 

Note: In above we only checked InternalState  is 2 or 4. Which are SPWorkflowState enumeration values of "Running" and "Completed"

The complete set of status are:

None

0

Locked

1

Running

2

Completed

4

Cancelled

8

Expiring

16

Expired

32

Faulting

64

Terminated

128

Suspended

256

Orphaned

512

HasNewEvents

1024

NotStarted

2048

All

4095

I always found this code useful when client wants custom Context menu, or when managed code is not an option.

James Tsai

Blog Disclaimer