Nintex Workflow - using all Regex options in your actions

 

Nintex Workflows supports a Regular Expression action.  This action has a very simple configurable UI with only the "Ignore case" option.

But there are a number of other very interesting Regex Options that you may want to use in your pattern.  This blog article is about how to enable them, and what sort of patterns you might use them for.

 

Regular Expression Options

Making an educated guess that the Nintex workflows uses the standard .NET Regular Expression (System.Text.RegularExpressions.Regex) rather than implementing their own regex engine.  Here's a list of the Regular Expression Options supported in the .NET Framework.

http://msdn.microsoft.com/en-us/library/yd1hzczs.aspx

  • i = IgnoreCase (this option is available in the Nintex action)
  • m = Multiline, if enabled, ^ and $ matches beginning and end of each line, rather than the whole block of text
  • s = Singleline, if enabled, . (period) matches all characters including newline (\n), by default, the period character only matches [^\n] (any character except the newline).
  • n = ExplicitCapture, don't capture groups
  • x = IgnorePatternWhitespace, ignore unescaped whitespace, and allow inline # comments

 

Using Regex Options within a pattern group

.NET allows you to use regular expressions with special options within a pattern group.  To do this, the pattern is:

  • (?imnsx-imnsx:pattern)

You can read up about it here: http://msdn.microsoft.com/en-us/library/bs2twtah.aspx#group_options

Lets see some examples.

 

Using the multiline option

Example, given this block of text:

Dear John,

Thanks for the email.

/footer

We want to extract the line that has the word "thanks".

We can use this expression:

  • (?m:^.*thanks.*$)
  • multiline match of any line that contains the word thanks.  Match from beginning of line ^ to end of line $.

image

The results in the workflow:

image

 

Using the singleline option

Example, given this block of text:

Dear John,

Thanks for the email.

/footer

We want to capture everything before the /footer.

  • ^(?s:.*)(?=/footer)
  • use singleline option, match any character (including line breaks).  Use a positive look-ahead match on /footer, but don't actually include it in the pattern match result.

image

The results in the workflow:

image

SharePoint Saturday Sydney 2012

Thank you all for attending SharePoint Saturday, giving up your time.  Sydney marks the last of the 6 SharePoint Saturdays that I've had the privilege to present in this year, ticking off:

The best part of SharePoint Saturday is just meeting talking to the enthusiastic SharePoint fans and hear what people are doing out there.  Honestly, not many people are that crazy to give up a sunny Saturday to learn about SharePoint - you guys are amazing.

The worst part is the travel. 

 

Sydney SharePoint User Group

I was honestly surprised almost everybody already know about the Sydney SharePoint User Group.  We meet monthly in the CBD between 6-7pm on the 3rd Tuesday of the Month.  We actually start at 5:30pm to eat up all the pizza first, and for the guys that don't need to head home right away, join us at the pub and geek out.

Sign up here so you can see what topic is coming up next month:

 

Golf Course

The User Group gave away a Miniature Golf Course during the event.

The Miniature Book of Miniature Golf

If you didn't manage to win one, but is still interested in it, it's here:

 

Downloads

SharePoint Saturday Canberra 2012

I had the pleasure of presenting REST services and AJAX at Canberra again.  It was a fun and sunny day that started at 4am in the morning, and packing a sleeping mr4 into the car and drive down.  Mr4 and my wife went to see the Cockington Miniature Gardens for the day, leaving me to geek out with fellow crazy SharePoint Saturday-ers.

As promised, there are a number of links:

 

Some of the comparisons I've made in the talk:

  • In SharePoint 2013, Microsoft wants you to use the services to talk to SharePoint, either via the Client Object Model, or via JavaScript and REST.  They also provide a whole lot of service endpoints for you to use:
    • /_vti_bin/listdata.svc
    • /_vti_bin/*.asmx
    • /_api/
  • In SharePoint 2010, you don't have nearly as many service end points, nor all the capabilities, but you can build custom services (which BTW, will still work in 2013).  So if you want to future-proof your solutions it is good to start thinking about implementing services and keeping the Javascript UI tier separate from the underlying services.
  • In the SharePoint 2013 Azure Workflow model, you can't deploy workflow actions.  But you are given an out of the box action that will let you call web services.  So building custom services is still a good way going forward to implement functionality that you can then reuse.
  • Re-use everywhere:
    • InfoPath
    • Workflow Web Request action
    • JavaScript AJAX

SharePoint - showing Contacts in People Search results

 

Scenario:

  • You have a working and functioning People Search page, and it's used to show information (and lovely photos) of your employees and acting as a very capable office phone book.
  • HR now wants to add more people to the list, people that, for some reason (may be they are kiosk workers, or external contractors), don't have an Active Directory account.  The phantom people.

Solution:

  • Create a standard SharePoint Contacts list
  • Include this list as part of the People search scope
  • Configure Search Metadata Properties to bring across the correct Site Columns, ultimately, showing both Real users and Contacts from Contact List in the same People Search results.

 

Create a contact list

image

 

The Contact list doesn't come with a Contact Photo by default, we should add one

 

 

Configuring Search

  • Create a new Search Scope "Humans"

    image
  • Add rules, in addition to the rule to include People, which is "contentclass = urn:content-class:SPSPeople"
    Add rule to also include Folder = http://server/Lists/Contacts

    image
  • You'll need to do a full crawl, which will pick up the Contact list, this will also pick up a crawled property for Contact_x0020_Photo
  • Then update the Scopes

 

Configure Search Page

 

  • Configure the Search Page
    • Change People Search Core Results webpart:
    • Scope: humans
    • Use Location Visualization: untick
    • Append Text To Query: scope:humans 
      (this allows your search results to show the first 20 people always, even when no query is specified)

 

Your search results should begin to show something, but it's not right:

image

  • Some fields are mapped automatically, here, the Job Title, Company, WorkPhone and Email fields have come across.  We're missing two significant ones

 

Configure Search Metadata Properties

 

  • Fix PreferredName

    image

    Add both "ows_FullName(Text) and ows_Full_x0020_Name(Text)
    Tick "Include values from all crawled properties mapped
  • PictureUrl

    image

    Add ows_Contact_x0020_Photo(Text)
    Tick Include values from all crawled properties mapped
  • Full crawl again.

 

The End result

 

image

 

Real users and Contact list entries displayed together in the search results!

SharePoint - The object has been updated by another user since it was last fetched - while updating Site Columns

This is the second time I've been bitten by this error.

Exception:

The object has been updated by another user since it was last fetched

 

And both times I had forgotten why, and then panicked, then searched online, found articles talking about this, and figured it all out, only to recall in the last minute...

Hey, wait a minute, this happened before.

The story begins as soon as you are trying to update your site columns.  Either via the web UI, or via code, or via PowerShell.  And then you hit this error.

The cause:

This is most likely because you've created the site column using an invalid Schema XML, in particular, you've embedded the version field in the <Field> definition.

<Field Type="Text" DisplayName="OrganisationName" Required="FALSE" EnforceUniqueValues="FALSE" Indexed="FALSE" MaxLength="255" ID="{guid-xxx}" StaticName="OrganisationName" Name="OrganisationName" Version="1" ></Field>

 

The Version attribute could have got in via a number of means, but most likely you exported the existing Schema from somewhere and it got embedded.

 

My explanation:

When you update a site column, SharePoint expects that the version number of this site column object increments after the update.  But because you are updating the site column via Schema and forcing the version to be fixed all the time, that number doesn't increment.  SharePoint now thinks there's something really wrong.

 

The Fix:

Remove the Version attribute from the Field definition, and then redeploy that definition to the server.

<Field Type="Text" DisplayName="OrganisationName" Required="FALSE" EnforceUniqueValues="FALSE" Indexed="FALSE" MaxLength="255" ID="{guid-xxx}" StaticName="OrganisationName" Name="OrganisationName" ></Field>