SharePoint – JQuery Scripts Examples

January 28, 2013

Lock input field and change background color

<br>/* --- Doc ready ---*/</p> <p>$(document).ready(function() {<br>/* --- End doc ready ---*/<br>/* --- Set Subject Read Only - Grey Color ---*/</p> <p>$("input[title='Subject']").attr("readonly","true").css<br>('background-color','#ccc').width(370);<br>});

Set a ‘To’ date field based on the ‘From’ date field. As you can see you need to find the proper field ID which is a long unique refference.

<br>/* Set Date Field "TO" based on the Date Field "FROM" */</p> <p>var sFrom= $("[name='ctl00$m$g_2a1915de_8d5b_445a_9443_...<br>Field$DateTimeFieldDate']").val();</p> <p>$("[name='ctl00$m$g_2a1915de_8d5b_445a_9443_2b18a9b32a7...<br>Field$DateTimeFieldDate']").val(sFrom);<br>;

The same as above but then on Change Event of the “From” date Field

<br>/* Set Date Field "TO" based on the Date Field "FROM" Change Event*/</p> <p>$('#ctl00_m_g_2a1915de_8d5b_445a_9443_2b18a9b32a70_ff3...<br>1_ctl00_ctl00_DateTimeField_DateTimeFieldDate').datepicker({<br>onSelect: function(dateText, inst)<br>{<br>$("[name='ctl00$m$g_2a1915de_8d5b_445a_9443_2b18a9b32a...<br>70$ff41$ctl00$ctl00$DateTimeField$DateTimeFieldDate']").val(dateText);<br>}<br>});<br>

Later I will add the print screen of how it looks :

SharePoint -JQuery Tools

January 28, 2013

Recently I needed to break out of the limited features that SharePoint had to offer out of the box. Condition was not to start programming, and especially not to change anything in the Backend of the SP Server.

So the solution was to turn to JScript, it runs client side !

Figure 1. Client Object Model Architecture


JavaScript Class Library

But with nearly ever touched JScript this would take me a while to get into it.

So the final solution came for the JQuery Library.

How to install the JQuery library

jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. With a combination of versatility and extensbility, jQuery has changed the way that millions of people write JavaScript.

And the related SharePoint specific derivate tools, like :

SPFF Field assistant (needs JQuery Libr.)

Dynamic Forms (needs JQuery Libr.)

SPServices on Codeplex (needs JQuery libr.)

SPAPI Webservices Libr (needs JQuery libr.)

Jpoint API Framework Client side

Some examples in a next post.

PowerShell – list MS Exchange Certificates

January 26, 2013

How to list the available certificates on your exchange server, when you run into an event ID 12014 error.

<br>CLS</p> <p># Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010</p> <p># Add Exchange 2010 commandlets (if not added)<br>if(!(Get-PSSnapin | <br>Where-Object {$ -eq <br>"Microsoft.Exchange.Management.PowerShell.E2010"})) {<br>ADD-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010<br>}</p> <p>Get-ExchangeCertificate | fl <br>

Output is like this :

AccessRules        : {System.Security.AccessControl.CryptoKeyAccessRule, …
CertificateDomains : {,,}
HasPrivateKey      : True
IsSelfSigned       : False
Issuer             : CN=Trusted SSL CA, O="Trusted, Inc.", C=US
NotAfter           : 3/04/2019 7:53:44
NotBefore          : 1/03/2012 16:25:22
PublicKeySize      : 2048
RootCAType         : ThirdParty
SerialNumber       : 014xxx
Services           : None
Status             : Valid
Subject            :, OU=Group - IT, O=Group, L=Local, …
Thumbprint         : 0AE4D67E3BC6CBA5AFBD3...

PowerShell – List Modules & SnapIns

January 26, 2013

How to list all available Powershell modules and SnapIns

# list available modules on a the server
Get-Module -ListAvailable
# Get-Module -ListAvailable | Import-Module

# Import the ActiveDirectory cmdlets
Import-Module ActiveDirectory

# For Exchange you can list it using
# List available snapins on your system:

# List registered snapins
Get-PSSnapin -Registered

So it all depends a bit on what you are looking for.


PowerShell – IDE missing on Servers ?!

January 26, 2013


On Windows Server 2008R2 this PS IDE is not installed by default ?

So you need to add it the feature yourself.




Import-Module ServerManager  
Add-Windowsfeature PowerShell-ISE

I hope this helps !

SharePoint Formula syntax errors !

January 24, 2013

Took me hours to find out why a simple formula as this one did always end up in a Correlation Error !

=DATEDIF([Column1], [Column2],“d”)

And answers is simple, when logging on to a Remote Deskop using a different regional settings, you need to use

=DATEDIF([Column1]; [Column2];“d”)

An other example that might be usefull to know

=TEXT(From;”yyyy”) results in 2013

=TEXT(YEAR([Start Date]))  results in 2.013


Enjoy !

SharePoint – How to Export Forms & WFs

January 24, 2013

Sometimes the way to do things is hard to find. Specially in SharePoint designer !

So I looked for an easy was to export all my Custom Forms, WorkFlows, Views etc.

Here’s how :

Open SPD and go the Site –> List you want to export form.


You see the custom Views / Forms / Workflows etc.

on the top press the little triangle to get to the dropdown menu.


Click for instance on Workflows to get the list of available WF’s.


Next on the top menu you can select the EXPORT File (see red arrow).

This will export the WF pages not the Workflow logic, lets say.

Therefore you need to do this procedure :

Open the WF in SPD and then click Export to VISIO


I hope this helps you find your way around SPD.

PowerShell – How to call a Web Service

January 22, 2013

Simple as of PS v2.0 you can use the

New-WebServiceProxy object to get data from a Web Service API in just a few lines.

$Weather = New-WebServiceProxy -Uri `

# Or this one, look at the Expand table option !
$zip = New-WebServiceProxy -Uri 
$zip.GetInfoByCity('New York')|select -expand table|ft city, state, zip, area_code -auto

This is the XML output :

<?xml version="1.0" encoding="utf-16"?>
<CurrentWeather>   <Location>Antwerpen / Deurne, Belgium (EBAW) 51-12N 004-28E 14M</Location>   <Time>Jan 22, 2013 - 03:20 AM EST / 2013.01.22 0820 UTC</Time>   <Wind> from the E (090 degrees) at 3 MPH (3 KT):0</Wind>   <Visibility> less than 1 mile:0</Visibility>   <SkyConditions> mostly cloudy</SkyConditions>   <Temperature> 26 F (-3 C)</Temperature>   <DewPoint> 24 F (-4 C)</DewPoint>   <RelativeHumidity> 92%</RelativeHumidity>   <Pressure> 29.65 in. Hg (1004 hPa)</Pressure>   <Status>Success</Status>

Enjoy !

PowerShell – How to enumerate List / Libr. Properties

January 21, 2013

Sometimes you want to get some list or library properties for whatever reason.

In my case I needed it to document the SP application we built.

This Example exports field properties like Description to Excel


$URL = "http://YourServer/"
$Lib = "HelpDesk"
$Out = "D:\temp\"

$site= New-Object Microsoft.SharePoint.SPSite ($URL)


write-host ""
#$list | Select Title, Description  
write-host ""
write-host "Records : " $list.ItemCount
write-host ""
$list.Fields | select parentlist, ID, internalname, title,  `
   Description, CanBeDeleted, Required, Hidden, Group `
 | where {$ -eq "Custom Columns" -and $_.CanBeDeleted -eq `
   $false -and $_.Hidden -eq $false -or $_.Required -eq $true} `
 | Sort-Object title | Export-CSV ($Out + $Lib + ".csv")

Enjoy !!

PowerShell – Using AutoIT COM object

January 21, 2013


This example shows how to run the AU3 Com object in Powershell.

# AutoIT declare object in PS
$oAutoIt = New-Object -comobject AutoItX3.Control

# This will List all the methods and properties of the COM object
$oAutoIt | get-member

# This will create a tooltip in the upper left of the screen
$oAutoIt.ToolTip("This is an AU3 tooltip Example" , 300, 430) 

# Important don't leave a spaces after the properties like this
# is wrong $oAutoIt.Sleep (2000) but like this =&amp;gt; $oAutoIt.Sleep(2000)


You can use any COM object in Powershell as you can see.

For a .Net assambly or Powershell integration look here

Enjoy !