Regex to validate title text in InfoPath

Requirement – InfoPath form title column should allow only alphabets and numbers to be keyed in, no special characters should be allowed.

Solution – Write a validation rule for the column. The condition would be

Field: Title

Condition: does not match pattern

Custom pattern:  -?[ a-zA-Z0-9]*[ a-zA-Z0-9]+



Send emails to distribution lists using SharePoint

It is easy to send emails to shared mailboxes or to distribution lists (DL) using your outlook. But have you ever wondered what happens when you try sending email to a DL using SharePoint (workflow).

I had the requirement to send emails to multiple DLs using my workflow and a 2 hours estimated work took me nearly 2 days to complete.

Basically, the email id of the DL won’t appear in your active directory while you search for it. Also, it is fair enough since a DL has no physical mailbox associated to it, just an id. Hence, the email id of the DL won’t be resolved.

Solution – Email enabled security group!!

In order to send emails to a DL from SharePoint, the DL needs to be converted to a security group that is email enabled. The same setting can be done by the exchange engineer either through command prompt or through exchange console. Below steps can be followed

  1. Go to Exchange Management Console -> Recipient Configuration -> Distribution group.
  2. Right-click on the problem group (i.e. the DL or the security group) and choose properties.
  3. On the Mail Flow Settings tab, double click on Message Delivery Restrictions.
  4. Uncheck the check box “Require that all senders are authenticated”.


Once done, the DL’s id can easily be searched in SharePoint’s directory and emails can be sent using workflows. However one thing to be kept in mind, it is the description or the display name that can be searched and not the DL’s email id directly.

Hope this helps!



2015 in review

Thank you all for the wonderful response. I want to thank each one of you for visiting my blog.

I wish you all a very happy new year 2016…


The stats helper monkeys prepared a 2015 annual report for this blog.

Here’s an excerpt:

Madison Square Garden can seat 20,000 people for a concert. This blog was viewed about 68,000 times in 2015. If it were a concert at Madison Square Garden, it would take about 3 sold-out performances for that many people to see it.

Click here to see the complete report.

Publishing a Nintex workflow to lists & libraries in multiple sites

My previous post was how can a Nintex workflow be published to multiple lists in the same site.
This time, it is a slight variation. The question this time is how can a workflow be published to multiple lists that reside on different sites.

Interesting stuff!! Trust me 🙂

Let me tell you how I came to this scenario

I have a site that is saved as a template, and close to 200+ sites have been created out of that template. All worked great until one day when I received this request for a change in one of my workflows in one of the lists of the site.

Also, this change had to be copied to almost 40 out of the 200 sites created.

Of course, I made the changes in the template site, but the challenge was how do I publish my updated workflow to the said sites.

This happened to be a slight extension to the same methodology that was used previously. Continue reading

Publishing a workflow to multiple lists and libraries (in same site!)

Requirement – I have a site that has around 40 country lists which have the same workflow. When there is a change in the workflow, there is a need to update the workflow in all 40 lists; which is practically impossible. Also, it wouldn’t be considered a good practice.

As most of the times, I knew there was a solution using Nintex. And the  moment I found it, I fell even more in love with this workflow tool. It keeps surprising me as always!

Solution – Nintex workflow comes with a web method called PublishFromNWFXML that will do this job for us.
Update your workflow at the parent location and export it. Upload the nwf file to a library (here – Shared Documents) and create the below workflow on this library, that will update it to the multiple lists.

Continue reading

Remove html tags from SharePoint list’s display form

Many a times, specially for look up columns in a SharePoint list, the display form returns html tags instead of the value.

For instance, below image has a look up field called Office, that shows the complete anchor tag instead of the value.


This happens while assigning the xsl value to a field in the display form. The optional attribute called “disable-output-escaping” plays the key role here. If it is set to ‘no’ (which is by default), special characters (like ‘<‘) will be output as ‘&lt;’. And if it set to ‘yes’, it means that special characters (like ‘<‘) should be output as is.

Hence, to implement this, open the display form in SharePoint designer and add this attribute i.e. disable-output-escaping=”yes” to the <xsl> tag.
For above example, the solution would be

    <td width="190px" valign="top" class="ms-formlabel">
	<H3 class="ms-standardheader">
    <td width="400px" valign="top" class="ms-formbody">
	<xsl:value-of select="@Office" disable-output-escaping="yes"/>

Change default font of a rich text box in SharePoint

Requirement – To change the default font – style of the rich text box
The multiple lines of text field, when selected as rich text or enhanced rich text has an advantage of styling the content inside at the run time, which is actually very helpful.

But then I ran into the situation where the user asked me to change the default font-style and font-size. They didn’t wanted to go through the process of changing the styles every-time a user fills in the rich text box. Also, this was to ply with the organization’s standard styles.

So, the solution is to write css.

The default style is defined in the core.css file. Hence, to change the default values, either a new css can be created or the style can be written in a content editor web part of the new form. The class for the rich text box is .ms-rtestate-write.

Below is the css to style the rich text box.

<style type="text/css">
       FONT-FAMILY: Calibri; 
       COLOR: grey; 
       FONT-SIZE: 11pt

jQuery to validate a people picker control for blank value in SharePoint

jQuery has made lives simpler by the validation techniques it uses. However, it can be big pain also the way it deals with various kind of controls. My case was to validate the people picker control.

The usual technique is to find the control, then match the value or text in the control to blank… and boom!!! you’re done with the validation.
But this seemed to work for the text boxes, drop downs, etc. The people picker, however, was returning by default the value – “&#160”. This is the blank value, but it never returned true upon comparison with blank.

So, the catch here is to find the correct control. It is not the people picker, instead you need to find the div with the id ‘divEntityData’. Then do the comparisons as in below code. It first checks the length, if nothing is entered. Later, if you’ve entered any value in the people picker, it will check whether it is resolved or not using the attribute “isresolved”. Use the below code for your reference.

function IsPeoplePickerValueResolved() { 
   var eEntityData = $("div[id='divEntityData']");
   if(eEntityData.length == 0)
   		alert("Please enter a user for this user field");
   		return false;
   else if(eEntityData.length > 0 ) 
       var isResolved = eEntityData.attr("isresolved");
       if(isResolved == "True")
	       return true;
	     alert("Please select correct name and resolve it");
	     return false;
	   return false;

Hope you could save some time with this.

Get the item count in a list inside a SharePoint site using PowerShell (Iterate through all subsites)

Here I got my first chance to work with PowerShell and I made it a point to write about this to keep this learning with me.

Requirement – Find the number of items in a list inside a site present in a site collection.

This is as simple as going inside that particular site and check the item count. But the catch was to find item count in 200+ sites present inside a site collection. Now, this isn’t a simple task anymore (lot of manual work, i hate it). Hence, I chose to use PowerShell.

Below is the script that I used. It instantiates the site collection and then iterates through all the sites inside it. Then it looks for the specific list and gets the count. The output for the same is written into an excel file in the defined format.

 $OutputFile = "C:\Users\spdev1glo\Desktop\Powershell"
 $Result = @()
 $siteCollectionURL = "http://****/sites/DemoPowershell/"
 $siteColl = Get-SPSite $siteCollectionURL
 if($siteColl -ne $null)
    foreach($web in $siteColl.AllWebs)
     if($web -ne $null)
		$sourceListName = "TaskList"
		$spSourceList = $web.Lists[$sourceListName]
		$itemCount = $spSourceList.Items.Count
		$Result += New-Object PSObject -Property @{
                'List Title' = $spSourceList.Title
                Count = $spSourceList.Items.Count
                'Site Title' = $web.Title
                 URL = $web.URL

$Result | Select 'Site Title',URL,'List Title',Count | Export-Csv "$OutputFile\SPListReport.csv" -NoTypeInformation


Read the recurring event and calculate the date of next occurrence using Nintex – Part 2

In my previous post Reading the recurring events in a SharePoint calendar using Nintex – Part 1, I discussed how the data gets structured in the XML format when a calendar event happens to be recurring. Now let us focus on how to extract the required information from that XML and calculate the next occurrence of the event. This will enable us to send reminder emails to the users before the event.

You ought to have a lot of patience since there is quite a lot of work posted here. Be persistent!

Continue reading