Tag: SharePoint

Reusing Css styles in Nintex Workflow notification emails

Workflows can have a lot of notifications and customizing and reformatting them individually can take a bit of time, perhaps a better way would be to apply css styles somewhere in a single css file and reuse it through out.

Nintex Workflow uses a css file containing default styles which it embeds within emails. We can easily create a copy it with our custom styles and this way we can avoid changing css for every single notification and also if we want to apply a simple change to all notification emails, it can be simply be applied to this single file.

To do this, let’s first download the default css file. Please go to Central Administration, Nintex Workflow Management and then Global Settings, you will see a link to css file

Paste this url in the browser to download this css, it would be something like http://SharePointServer:Port/_layouts/15/NintexWorkflow/HtmlEditorStyles.css

Let’s rename this file to avoid overwriting the default and edit it.

Now to publish changes upload the new file to anywhere in layouts folder, change the link above and save it.

There a quite a few style rules in this css, Be mindful of the comments above which states that each style rule must be followed by a { on the next line and end with a } on its own line for the parser to function correctly

All have the styles have some meta data information embedded with “–ms-” prefix and this is how email editor maps styles. For example at the top there are styles for colors with –ms-color prefix and some colors, if we take the first one, -ms-color says “Dark Red” and now we see it in email editor there is a Dark Red color as well, now we change color attribute value here we can use this in the editor, we can even change names so it is easier to find.

.ntx-rteForeColor-1
{
  color: darkred;
  -ms-name: "";
  -ms-color:"Dark Red";
}

Likewise there are styles for Fonts, Headings and others. To change default font and styles in body, we can make changes in following rule

.ntx-rte-messageBody
{
  font-family: Calibri, Verdana, Arial, Sans-Serif;
  font-size: 11pt;
  color: Black;
}

One of the most frequently used one would be changing styles for tables. Default styles are listed in design tab in ribbon upon selecting a table and we can customize one these styles.

In the CSS file these styles are named with –ms-name attribute, try searching for “Table Style 2 – Medium” and then you can which style is being used. Following are rules being applied to this table design

.ntx-rteTable-1
{
  -ms-name:"Table Style 2 - Medium";
  border-width: 0px;
  border-style: none;
  border-collapse: collapse;
  font-family: Tahoma;
}

.ntx-rteTable-1 tr.ntx-rteTableHeaderRow-1
{
  margin: 10px;
  padding: 10px;
  color: #3F4D6B;
  background: #D6E8FF;
  text-align: left;
  font-size: 10pt;
  font-style: normal;
  font-family: Tahoma;
  text-transform: capitalize;
  font-weight: bold;
  border-spacing: 10px;
  line-height: 14pt;
  vertical-align: top;
}

.ntx-rteTable-1 td.ntx-rteTableHeaderFirstCol-1
{
  padding: 0in 5.4pt 0in 5.4pt;
  color: #3a4663;
  line-height: 14pt;
}

.ntx-rteTable-1 td.ntx-rteTableHeaderLastCol-1
{
  padding: 0in 5.4pt 0in 5.4pt;
  color: #3a4663;
  line-height: 14pt;
}

.ntx-rteTable-1 td.ntx-rteTableHeaderOddCol-1
{
  padding:0in 5.4pt 0in 5.4pt;
  color: #3a4663;
  line-height: 14pt;
}

.ntx-rteTable-1 td.ntx-rteTableHeaderEvenCol-1
{
  padding:0in 5.4pt 0in 5.4pt; color: #3a4663;
  line-height: 14pt;
}

.ntx-rteTable-1 tr.ntx-rteTableOddRow-1
{
  color: #666666;
  background-color: #F2F3F4;
  font-size: 10pt;
  vertical-align: top;
}

.ntx-rteTable-1 tr.ntx-rteTableEvenRow-1
{
  color: #666666;
  background-color: #E7EBF7;
  font-size: 10pt;
  vertical-align: top;
}

.ntx-rteTable-1 td.ntx-rteTableFirstCol-1
{
  padding: 0in 5.4pt 0in 5.4pt;
}

.ntx-rteTable-1 td.ntx-rteTableLastCol-1
{
  padding:0in 5.4pt 0in 5.4pt;
}

.ntx-rteTable-1 td.ntx-rteTableOddCol-1
{
  padding: 0in 5.4pt 0in 5.4pt;
}

.ntx-rteTable-1 td.ntx-rteTableEvenCol-1
{
  padding:0in 5.4pt 0in 5.4pt;
}

.ntx-rteTable-1 tr.ntx-rteTableFooterRow-1
{
  background-color: #D6E8FF;
  color: #4A5A80;
  font-weight: 500;
  font-size: 10pt;
  font-family: Tahoma;
  line-height: 11pt;
}

.ntx-rteTable-1 td.ntx-rteTableFooterFirstCol-1
{
  padding: 0in 5.4pt 0in 5.4pt;
  border-top: solid gray 1.0pt;
  text-align: left;
}

.ntx-rteTable-1 td.ntx-rteTableFooterLastCol-1
{
  padding:0in 5.4pt 0in 5.4pt;
  border-top:solid gray 1.0pt;
  text-align:left;
}

.ntx-rteTable-1 td.ntx-rteTableFooterOddCol-1
{
  padding: 0in 5.4pt 0in 5.4pt;
  text-align: left;
  border-top: solid gray 1.0pt;
}

.ntx-rteTable-1 td.ntx-rteTableFooterEvenCol-1
{
  padding: 0in 5.4pt 0in 5.4pt;
  text-align: left;
  border-top: solid gray 1.0pt;
}

I hope you find this post useful, thanks.

Advertisements

Nintex Workflow 2010 – The workflow could not update the item, possibly because one or more columns for the item require a different type of information.

While trying to set field value or update list item action after set item permissions for setting workflow initiator’s permission to read only so that he or she could not modify the list item I was getting the following error in email.

The workflow could not update the item, possibly because one or more columns for the item require a different type of information.

On the workflow status page in the history list an event was logged with Error event type and outcome of that event was access denied.

After exploring a little bit I found out that this error was coming because Nintex workflow runs in the user context of initiator so if the initiator doesn’t have permission to modify list items set field value and update list items actions would fail.

There is a way to run the workflow in the context of user who publishes it. Thia option can be enabled by editing an action, go to common settings and then enable “Run as workflow owner”. This option is not available in all actions so to use it in actions where it is not available please drop an action set action in the workflow, enable this setting and then drop the actions you want to use, in my case I was using state machine workflow and then was using set field value.

image

I hope you find this post useful. Thanks for reading.

Powershell to create calendar in SharePoint with categorized overlays

Creating calendars in SharePoint 2010, changing default categories and then creating view and overlay for each category can take a lot of clicks. To save time and effort I created a powershell script which can be used as follows

& ‘.\Calendar Overlay.ps1’ -webUrl {SITEURL} -listName “{LISTNAME}” -categories “{CommaSeparatedCategories}”

It takes three command line parameters which are

-webUrl – The site url where you want to create the calendar

-listName – The name of calendar list

-categories – Comma separated values for categories

For example if you would like to create a calendar named Yearly events on http://myspsite/marketing with road show, marketing boot camp 1 and digital campaign 1. You can pass in the following arguments

& ‘.\Calendar Overlay.ps1’ -webUrl http://myspsite/marketing -listName “Yearly Events” -categories “Road show, Marketing Boot camp 1, Digital Campaign 1”

The resulting calendar would look like

Calendar overlays created with Powershell

Source for the script is as follows:

###############################################################################
# Creating Calendar overlays in SharePoint 2010 using Powershell
# Version          : 1.0
# Url              : https://khurrampunjwani.wordpress.com
# Creator          : Khurram Punjwani, http://twitter.com/khurrampunjwani
###############################################################################

param (
    [string]$webUrl = $(throw "-webUrl is required."),
	[string]$listName = $(throw "-listName is required."),
    [string]$categories = $(throw "-categories is required.")
 )

[array]$categoriesArray = $categories -split ","

Function Get-SPCalendarWeb(){

	#Clear screen first
	Clear-Host
	
	#Load web where Calendar is supposed to be created
	$web = Get-SPWeb -Identity $webUrl
	Write-Host "SP Web Loaded " $web.Title
	
	#Create new calendar
	New-SPCalendar

	$web.Dispose()
}

Function Add-TestEntries($cal){
	$listItem = $cal.AddItem()
	$listItem["Title"] = "Test 1"
	$listItem["Category"] = $categoriesArray[0]
	$listItem["EventDate"] = [System.DateTime]::Now
	$listItem["EndDate"] = [System.DateTime]::Now.AddHours(4)
	$listItem.Update()
	
	$listItem = $cal.AddItem()
	$listItem["Title"] = "Test 2"
	$listItem["Category"] = $categoriesArray[1]
	$listItem["EventDate"] = [System.DateTime]::Now
	$listItem["EndDate"] = [System.DateTime]::Now.AddHours(4)
	$listItem.Update()
}

Function New-SPCalendar(){
	$web.Lists.Add($listName,"",[Microsoft.SharePoint.SPListTemplateType]::Events)
	$cal = $web.Lists.TryGetList($listName);
	
	Write-Host "Calendar created"
	
	#Delete default categories and add the ones specified in command line
	Add-CalendarCategories $cal
	
	#Add Views with Filters
	Add-SPCalendarViews $cal

	#Add test entries
	Add-TestEntries $cal
}

Function Add-SPCalendarViews($cal){
	$view = $cal.Views["Calendar"]
	$viewFields = $view.ViewFields.ToStringCollection()
	$viewData = ""
    $viewData += ""
    $viewData += ""
    $viewData += ""
    $viewData += ""
	#XML for calendar overlays
	$calendarSettings = "  "
	#To show different color for category views
	$colorIndex = 1 
	
	#Create views for categories so there will be one view for each category
	foreach($category in $categoriesArray){
		#Create filter for the view to show events from the respective category
		$viewQuery = ""
		$viewQuery += ""	
		$viewQuery += ""
		$viewQuery += ""
		$viewQuery += ""
		$viewQuery += ""
		$viewQuery += ""
		$viewQuery += ""
		$viewQuery += ""
		$viewQuery += ""
		$viewQuery += %{"{0}" -f $category}
		$viewQuery += ""
		$viewQuery += ""
		$viewQuery += ""
		
		$newView = $cal.Views.Add($category,$viewFields,$viewQuery,3,$false,
			$false,"CALENDAR",$false)
		$newView.ViewData = $viewData
		$newView.Update()

		%{"View created for {0} category" -f $category} | Write-Host
		
		#Update XML for Calendar Overlay, each view would be added as an overlay
		$calendarSettings += %{"  " -f $category}
		$calendarSettings += %{"

Changing SharePoint 2010 lookup column Date Time and Number formatting

Few days back I was creating a report using SharePoint 2010 list as data source in Report Builder 3. The list I was using had the following lookup columns:

  • StartDate (DateTime Column)
  • FinishDate (DateTime Column)
  • Budget (Number)

Now when I tried to change the datetime and number formatting, I noticed formatting was not being applied.

After spending some time I found out that in order to apply number and datetime formatting to lookup columns, they must be converted to a proper data type. So instead of binding field directly to a column, I used the following expressions to convert these lookup columns in proper data types

Convert SharePoint 2010 lookup column to proper data type

The complete list of conversion functions can be found under Common functions and then Conversion. In my case for dates I used CDate(FieldName) and for number column I used CInt(FieldName)

Convert SharePoint 2010 lookup column to proper data type

Why AutoSPInstaller?

Let’s assume we’ve to create a new SharePoint 2010 server so we install SharePoint 2010 and then start the configuration wizard. After we’re through with the configuration wizard, most probably when we’ll start SQL Server Management Studio we’ll see something like the following

SharePoint Databases with Guids

This type of inconsistent naming can be very unpleasant and might not be very handy for our DBAs, wouldn’t it be better if we’d something like

So what we do. We can run some powershell scripts to manually configure our Farm and install services (For more details, please visit http://technet.microsoft.com/en-us/library/cc262839.aspx#section6)

Another good alternate is that we use AutoSPInstaller which can automate the process of installing (including downloading and installation of pre- requisites) and configuring SharePoint 2010 based on inputs we provide in an xml file. There is an editor available to edit scripts for AutoSPInstaller as well called AutoSPInstallerGUI

For detailed instructions on how to use AutoSPInstaller, please visit http://www.softlanding.ca/Blog/Lists/Posts/Post.aspx?ID=30.

Thanks for reading. I hope you found this post useful. Please don’t forget to share this post. Cheers

How to add or remove languages from Advance Search Page in SharePoint 2010

Changing the language list on Advance search page is very simple, just follow these steps.

Step 1: Go to Advance page, site actions and then edit page.

Step 2: Now edit advance search box web part and collapse properties section.

Step 3: Copy xml from properties textbox and paste it in any xml editor like Visual Studio so we can modify it easily

Step 4: Search for languages tag and remove any language that is not necessary from the list. For example let’s remove all languages except English from the list, now it should look like

<Languages>
<Language LangRef="en" />
</Languages>

Step 5: To add another language, just add another Language element with LangRef attribute. Values for LangRef attribute will LangID from the LangDefs element. For example if we want to add Arabic then our Languages element would look like

<Languages>
<Language LangRef="en"/>
<Language LangRef="ar"/>
</Languages>

Step 6: Copy the entire xml and paste it in properties textbox in advance search box web parts (Where we initially copied the xml from) and save the page.

That’s it we are done.

I hope you find this post useful. Thanks

How to add global navigation in SharePoint 2010 Fast or Enterprise Search Center Sites

This post describes how we can add global navigation in SharePoint 2010 Search Center sites.

Search center sites use minimal master page which doesn’t include global navigation controls. Even if we change site’s master page (To change master page, publishing feature has to be activated) from minimal to v4 or nightandday global navigation will not appear and we’ll see some strange results like search textbox going behind the ribbon. The reason for this is that the controls which render global navigation are not in minimal master page, they are in page layouts. So let’s start our short journey.

Step 1: Open root site in SharePoint Designer, go to All Files, _catalogs and then masterpage

Step 2: We’ve to change SearchMain.aspx (default page containing search text box), SearchResults.aspx (which shows search results) and AdvanceSearchLayout.aspx (which has advance search controls) respectively

Step 3: Let’s start with SearchMain.aspx, click this file, edit it and then click Advance mode button at the top so we can do the desired changes.

Step 4: Search for srch-sb-main, we’ve to paste the following code which renders the global navigation before div with class srch-sb-main

<div class="s4-lp s4-toplinks" style="background-image:url(/_layouts/images/selbg.png); background-repeat:no-repeat;
repeat-x:left top; background-color:#f6f6f6; vertical-align:middle; min-height:25px; border-top:1px solid #e0e0e0;
border-bottom:1px solid #b8babd">

<SharePoint:AspMenu
ID="TopNavigationMenuV4"
Runat="server"
EnableViewState="false"
DataSourceID="topSiteMap"
AccessKey="<%$Resources:wss,navigation_accesskey%>"
UseSimpleRendering="true"
UseSeparateCss="false"
Orientation="Horizontal"
StaticDisplayLevels="2"
MaximumDynamicDisplayLevels="1"
SkipLinkText=""
CssClass="s4-tn"/>

<SharePoint:DelegateControl runat="server" ControlId="TopNavigationDataSource" Id="topNavigationDelegate">
<Template_Controls>

<asp:SiteMapDataSource
ShowStartingNode="False"
SiteMapProvider="SPNavigationProvider"
id="topSiteMap"
runat="server"
StartingNodeUrl="sid:1002"/>

</Template_Controls>
</SharePoint:DelegateControl>

</div>

Step 5: Let’s save our page and view it in browser.

Step 6: Okay we got our global navigation on search page, now let’s add it in search results page. So let’s edit SearchResults.aspx in advance mode

Step 7: Search for srch-sb-results, we’ve to paste the code from step 4 which renders the global navigation before div with class srch-sb-results

Step 8: Search for PlaceHolderMain, we’ve to paste the code from Step 4 which renders the global navigation inside the content place holder with id PlaceHolderMain