Microsoft SharePoint and .NET Technology Insight

SharePoint, .NET, Office365, Windows Azure, TFS, Project Server and SQL Server Technology Insights


Leave a comment

Dynamically updating URL links within a SharePoint 2010 Content Editor Web-Part (CEWP) and reading the values from a SharePoint list using JQuery

Here is an example of dynamically updating URL links within a SharePoint 2010 Content Editor Web-Part (CEWP) and reading the values from a SharePoint list using JQuery:


<script type="text/javascript">

function processResult(xData, status) {
$(xData.responseXML).find("z\\:row").each(function() {

var keyResources1 = $("#KeyResourcesMain");
var url = $(this).attr("ows_LinkUrl");
var htmlTimeSheet = "<li><a href = " + url + ">My TimeSheet</a></li>";

keyResources1.append(html);
keyResources1.append(htmlTimeSheet);

});
}

$(document).ready(function() {
var soapEnv = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'><soapenv:Body><GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'><listName>Popular Links</listName><query><Query><Where><Eq><FieldRef Name='Title'/><Value Type='Text'>My Timesheet</Value></Eq></Where></Query></query><viewFields><ViewFields><FieldRef Name='LinkUrl' /><FieldRef Name='Title' /></ViewFields></viewFields></GetListItems></soapenv:Body></soapenv:Envelope>";
$.ajax({
url: "/_vti_bin/lists.asmx",
type: "POST",
dataType: "xml",
data: soapEnv,
complete: processResult,
contentType: "text/xml; charset=\"utf-8\""
});
});

</script>

<div><h3>Key Resources</h3>
<ul id="KeyResourcesMain"></ul>
</div>

The above approach of using the JQuery Document.Ready Function is better when compared to using the JavaScript _spBodyOnLoadFunctionNames and loads a custom user defined Javascript during rendering of a page instead of loading the Custom JavaScript after rendering of the page is completed.

The functions in _spBodyOnLoadFunctionNames run after the page is finished rendering by definition. In SharePoint 2010, this effect may be more visible since in SharePoint 20010 there is more Out of box JavaScript that runs during page load. You could try to accomplish UI updates (for example updating URLs in a CEWP from SharePoint Lists as in the above example) using the server-side APIs (e.g. content placeholders, delegate controls) or using JQuery and running your script on document ready instead of waiting for the page to call the customr script after other SharePoint 2010 out of box Javascript code on is done loading on the page.

Advertisements


Leave a comment

Sharepoint Adding a Mapped URL programmatically

With SharePoint 2010 you can now set your own custom error pages. This has been a much asked for feature from allot of my customers and has the potential to offer a much  better user experience. In fact, one which you may choose to vary depending on the role of the user. For example, you may want to provide a very generic error for anonymous users and a much more detailed error of the user happens to be the site collection owner or farm admin.

Its not only the error pages that got all the love here, in fact you can customize the Access Denied, Confirmation, Login, Request Access, Sign-out, and Web Deleted pages. The SPWebApplication.SPCustomPage enumerator is used to pass the page which you wish to override into a call to UpdateMappedPage() along with the path to the custom page. So once set, this page will be used anytime a request is made for the corresponding page. Since this method is part of the SPWebApplication you will note a custom pages are scoped to the web application.

We can make use of GetMappedPage and UpdateMappedPage  methods. This can be done by creating a Web scoped Feature writing your code in Feature Activated and Deactivated methods as:

public override void FeatureActivated(SPFeatureReceiverProperties properties)
{

SPWebApplication webApp = properties.Feature.Parent as SPWebApplication;

try
{

if (webApp != null)
{
if (!webApp.UpdateMappedPage(SPWebApplication.SPCustomPage.AccessDenied,
“/_layouts/CustomAppPagesFolder/CustomAccessDenied.aspx”))
{
throw new ApplicationException(“Error adding mapped page.”);
}

// File Not Found page is set differently.
webApp.FileNotFoundPage = “/_layouts/1033/CustomFolder/FileNotFoundPage.htm”;
webApp.Update(true);
}
}
catch (Exception Ex)
{
throw ex;
}
}

public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
{
SPWebApplication webApp = properties.Feature.Parent as SPWebApplication;
try
{
if (webApp != null)
{
//you have to set the property back to null for setting it to default
webApp.UpdateMappedPage(SPWebApplication.SPCustomPage.AccessDenied, null);

//File not found is handled differently
webApp.FileNotFoundPage = null;
}
}
catch (Exception Ex)
{
throw ex;
}
}
}

 


1 Comment

SharePoint to SAP Integration and third party products

SharePoint to SAP Integration and third party products:

Here are the list of current third-party vendor solutions which can be used for SharePoint to SAP integration.

1. MyOVS HR for SAP provides 7 modules for SAP HCM which have webparts for SharePoint 2007, 2010. There are additional integration options with .NET Platform. Get additional information here

2. ERPConnect services include multiple components for integration between SharePoint and SAP including ERPConnect Services Runtime for using SharePoint as a data hub while accessing SAP, BCS connector to connect SharePoint lists with SAP tables or objects and Xtract PPS for PerformancePoint Dashboard integration with SAP values. Get additional information here.

3. Sitrion solutions provide several App templates for SharePoint integration with SAP Employee Self Service and Manager Self-service. Additionally, the Sitrion Visual Studio integrated development tool namely Sitrion Service Studio consists of certified adapters for all general SAP systems and releases for connection to your SAP systems allowing for development of .NET components exposed as WCF services which encapsulate invocation of SAP RFCs and functions. These Sitrion WCF services can then be leveraged within Custom SharePoint code include web-parts, workflows and lists. Get additional information here

4. ERP-Link’s iNET platform exposes native SAP information, business, and document objects as .NET ready and therefore easily integrated with SharePoint and SharePoint-based processes and applications. Get additional information here

5. Duet Enterprise for Microsoft SharePoint. Additional Information here

 

Additional non-third party options including using SharePoint 2010’s BCS component and LINQ to SAP to integrate SAP Business Data into SharePoint 2010. See example here.