Archive

Posts Tagged ‘SharePoint2010’

How to replace the SharePoint date calendar control with more user friendly jQuery calendar control

April 26, 2014 1 comment

When you use the SharePoint date and time type for date of birth field, you will notice that the calendar control is extremely non-user-friendly. You can only navigate month by month as shown below. To resolve the issue, you can customize the list form page using SharePoint designer and replace the OOB calendar control with popular jQuery control. The solution works for both SharePoint 2010,2013 and office365.

Here are the steps for how to achieve this.

1. Open SharePoint designer and create a New List Form called customNew and set as default form for the selected type.

2. Open style library in file explorer and copy jQuery and jQuery UI files into the style library in SharePoint site.

You can download the jQuery and jQuery UI from the web and the content of the contactPersonCustomNewForm.js is as below. I use the dd/mm/yy format as my locale in Regional Settings is English(New Zealand). You need to change this if you live in another country with different date format

$(document).ready(function() {
    	$("img#ctl00_m_g_540b9a50_52dc_4400_a58d_1db99555fddf_ff41_ctl00_ctl00_DateTimeField_DateTimeFieldDateDatePickerImage").parent().hide();
 		$("img#ctl00_m_g_540b9a50_52dc_4400_a58d_1db99555fddf_ff41_ctl00_ctl00_DateTimeField_DateTimeFieldDateDatePickerImage").hide();
	    $("input#ctl00_m_g_540b9a50_52dc_4400_a58d_1db99555fddf_ff41_ctl00_ctl00_DateTimeField_DateTimeFieldDate").datepicker({
		    changeMonth:true,
		    changeYear:true,
		    showOn: "button",
			buttonImage: "/_layouts/images/calendar.gif",
			buttonImageOnly: true,
			defaultDate:"01/01/1970",
			yearRange: "c-20:c+20",
			dateFormat: "dd/mm/yy"
	    });
});

In order to get the image and textbox selector above , you can open IE developer toolbar(click F12) and find the control ID as below:

3. Open SharePoint designer and edit the newly created New List Form customNew.aspx in advance mode. Then copy and paste the following links in the PlaceHolderAdditionalPageHead.

	<SharePoint:CssRegistration name="<%$SPUrl:~SiteCollection/Style Library/themes/ui-lightness/jquery-ui.css%>" runat="server"/>
	<SharePoint:ScriptLink language="javascript" name="~sitecollection/Style Library/jquery-1.10.2.js" Defer="false" runat="server"/>
	<SharePoint:ScriptLink language="javascript" name="~sitecollection/Style Library/jquery-ui-1.10.4.custom.min.js" Defer="false" runat="server"/>
	<SharePoint:ScriptLink language="javascript" name="~sitecollection/Style Library/contactPersonCustomNewForm.js" Defer="false" runat="server"/>

 

4. Now go to the list and click add, you will see the new calendar control as shown below

How to create Office365 SharePoint site using SharePoint2010 template

July 15, 2013 1 comment

Recently, I worked with a client that has office 365 upgraded to SharePoint 2013.But they still like to create the SharePoint site using the old SharePoint2010 template, if you like to know how , here are the steps:

1. Go to your Office 365 portal https://portal.microsoftonline.com/admin/default.aspx and then go to the SharePoint admin page.

2. Next, click settings page.

3. Change the Global experience Version Settings.

4. Finally, you will be able to create SharePoint site using 2010 template.

How to copy items using Nintex Workflow

June 11, 2013 1 comment

Nintex does not offer copying items from one SharePoint library to another out of box. However, it is not hard to implement one yourself. You can use the copy.asmx web services to achieve this. Here are the steps below and you can download the source here

1. Create a UDA with the following parameters:

2. Call the copy.asmx service to copy the item from SouceItemUrl to DestinationItemUrl

3. If your destination document library has versioning and check-in/out turned on , you can use list.asmx to check in your file as below:

4. You need to create constant of Credential type named SP_WORKFLOW_WS as below

5. Here is how it looks like in the Workflow designer.

6. To call this UDA, you can perform the following in your workflow

How to write PowerShell code part 4 (using loop)

May 31, 2013 Leave a comment

In this post, I’d like to show you how to loop through the xml element. I will use the list data deletion script as an example. You can download the script here.

1. To perform the loop, I use foreach in powershell. Here is my xml looks like


<?xml version="1.0" encoding="utf-8"?>
<Site Url="http://workflowuat/npdmoc">
 <Lists>
 <List Name="YBBEST Collaboration Areas" Type="Document Library"/>
 <List Name="YBBEST Project" />
 <List Name="YBBEST Document"/>
 </Lists>
</Site>

2. Here is the PowerShell to manipulate the xml. Note, you need to get to the $configurationXml.Site.Lists.List variable rather than $configurationXml.Site.Lists


foreach ($list in $configurationXml.Site.Lists.List){
 AppendLog "Clearing data for $($list.Name) at site $weburl" Yellow
 if($list.Type -eq "Document Library"){
 deleteItemsFromDocumentLibrary -Url $weburl -ListName $list.Name
 }else{
 deleteItemsFromList -Url $weburl -ListName $list.Name
 }
 AppendLog "Data in $($list.Name) at $weburl is cleared" Green
}

How to write PowerShell code part 1
How to write PowerShell code part 2
How to write PowerShell code part 3
How to write PowerShell code part 4

Truly understand the threshold for document set in document library in SharePoint

January 27, 2013 Leave a comment

Recently, I am working on an issue with threshold. The problem is that when the user navigates to a view of the document library, it displays the error message “list view threshold is exceeded”. However, in the view, it has no data. The list view threshold limit is 5000 by default for the non-admin user. This limit is not the number of items returned by your query; it is the total number of items the database needs to read to calculate the returned result set. So although the view does not return any result but to calculate the result (no data to show), it needs to access more than 5000 items in the database. To fix the issue, you need to create an index for the column that you use in the filter for the view. Let’s look at the problem in details. You can download a solution to replicate this issue here.

1. Go to Central Admin ==> Web Application Management ==>General Settings==> Click on Resource Throttling

2. Change the list view threshold in web application from 5000 to 2000 so that I can show the problem without loading more than 5000 items into the list.

FROM

TO

3. Go to the page that displays the approved view of the Loan application document set. It displays the message as shown below although I do not have any data returned for this view.

4. To get around this, you need to create an index column. Go to list settings and click on the Index columns.

012613_2210_Trulyunders5.png

5. Click on the “Create a new index” link.

012613_2210_Trulyunders6.png

6. Select the LoanStatus field as I use this filed as the filter to create the view.

012613_2210_Trulyunders7.png

7. After the index is created now I can access the approved view, as you can see it does not return any data.

012613_2210_Trulyunders8.png

Notes:

List View Threshold: Specify the maximum number of items that a database operation can involve at one time. Operations that exceed this limit are prohibited.

References:

SharePoint lists V: Techniques for managing large lists

Manage large SharePoint lists for better performance

http://blogs.technet.com/b/speschka/archive/2009/10/27/working-with-large-lists-in-sharepoint-2010-list-throttling.aspx

How to create a link to Nintex Start Workflow Page in the document set home page

January 19, 2013 3 comments

In this blog post, I’d like to show you how to create a link to start Nintex Workflow Page in the document set home page.

1. Firstly, you need to upload the latest version of jQuery to the style library of your team site.


2. Then, upload a text file to the style library for writing your own html and JavaScript

3. In the document set home page, insert a new content editor web part and link the text file you just upload.

4. Update the text file with the following content, you can download this file here.

<script type="text/javascript" src="/Style%20Library/jquery-1.9.0.min.js"></script>
<script type="text/javascript" src="/_layouts/sp.js"></script>
<script type="text/javascript">
$(document).ready(function() {
    listItemId=getParameterByName("ID");
	setTheWorkflowLink("YBBESTDocumentLibrary");
});
function buildWorkflowLink(webRelativeUrl,listId,itemId) 
{ 	
	var workflowLink =webRelativeUrl+"_layouts/NintexWorkflow/StartWorkflow.aspx?list="+listId+"&ID="+itemId+"&WorkflowName=Start Approval";
	return workflowLink;
}
function getParameterByName(name)
{
	name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
	var regexS = "[\\?&]" + name + "=([^&#]*)";
	var regex = new RegExp(regexS);
	var results = regex.exec(window.location.search);
	if(results == null){
		return "";
	}
	else{
		return decodeURIComponent(results[1].replace(/\+/g, " "));
	}
}

function setTheWorkflowLink(listName) 
{ 	
	var SPContext = new SP.ClientContext.get_current(); 
	web = SPContext.get_web(); 
	list = web.get_lists().getByTitle(listName); 
	SPContext.load(web,"ServerRelativeUrl"); 
	SPContext.load(list, 'Title', 'Id');	
	SPContext.executeQueryAsync(setTheWorkflowLink_Success, setTheWorkflowLink_Fail); 
}
function setTheWorkflowLink_Success(sender, args) 
{ 
	var listId = list.get_id(); 
	var listTitle = list.get_title(); 
	var webRelativeUrl = web.get_serverRelativeUrl();
	var startWorkflowLink=buildWorkflowLink(webRelativeUrl,listId,listItemId)
	$("a#submitLink").attr('href',startWorkflowLink);
}
function setTheWorkflowLink_Fail(sender, args) 
{
	alert("There is a problem setting up the submit exam approval link");
}
</script>
<a href="" target="_blank" id="submitLink"><span style="font-size:14pt">Start the approval process.</span></a> 

5. Save your changes and go to the document set Item, you will see the link is on the home page now.

Notes:

1. You can create a link to start the workflow using the following build dynamic string configuration:

{Common:WebUrl}/_layouts/NintexWorkflow/StartWorkflow.aspx?list={Common:ListID}&ID={ItemProperty:ID}&WorkflowName=workflowname.
With this link you will still need to click the start button, this is standard SharePoint behaviour and cannot be altered.

References:

http://connect.nintex.com/forums/27143/ShowThread.aspx

How to use html and JavaScript in Content Editor web part in SharePoint2010

How to use the client object model with SharePoint2010

January 17, 2013 Leave a comment

In SharePoint2010, you can use client object model to communicate with SharePoint server. Today, I’d like to show you how to achieve this by using the c# console application. You can download the solution here.

1. Create a Console application in visual studio and add the following references to the project.


2. Insert your code as below

            ClientContext context = new ClientContext("http://demo2010a");
            Web currentWeb = context.Web;
            context.Load(currentWeb, web =&gt; web.Title);
            context.ExecuteQuery();
            Console.WriteLine(currentWeb.Title);
            Console.ReadLine();

3. Run your code then you will get the web title displayed as shown below

Note:

If you got the following errors, you need to change your target framework from .Net Framework 4 client profile to .Net Framework 4 as shown below:

Change from

TO