Skip Ribbon Commands
Skip to main content
Home
Personal experiences and findings related to SharePoint.
August 10
Default a Selection on a Multi Choice Check Box Control on a Nintex Form

​I have a Nintex form (SharePoint 2010 / Nintex Forms 2010) with a Choice Control that has a lookup to another list.  This control is set to have a display format of check boxes (mulitple-selection).  I want the first selection to be checked by default when a new form is opened.

I am not a JavaScript expert, but I am very good at copying code and pretty decent at figuring it out.  I found a forum post that had the answer to my question.

Here are the steps:

  1. In the Choice Control settings, make sure that the Display format is set to Check boxes (Multiple-Selection).

    ControlSettingDisplayFormat.jpg

  2. In the Advanced section, set Store Client ID in JavaScript variable to Yes.

    StoreClientID.jpg
  3. After this is set to "Yes", the Client ID JavaScript variable name field appears.  

    VarName.jpg

  4. In this field, enter a variable name.  This name will be used in the JavaScript code that you will enter into the Form Settings.  (I like to prefix all variables with "var".)

  5. Click Save.

  6. From the Nintex Forms toolbar, click Settings.

  7. Expand the Custom JavaScript section and enter the following code:

    CustomJavaScript.jpg

    NWF$(document).ready(function() {
    NWF$("#" + varIssue).val('1');
    } );

  8. Change "varIssue" to your variable name that you entered in Step 4.  (If you want a different checkbox selected other than the first, change the number "1" in "val('1')" to a different number.  The number represents the list order of the options.)

  9. Click Save.

  10. Preview your form.

  11. The box has a check!

    DefaultIssueChecked.jpg


May 22
"File is locked for editing by..."

I had a user that had made edits to a file and checked it back in. Other users were trying to open the file and make edits, but were receiving the error on edit that the file was locked for editing by the original user.

Ultimately, I had to run some Powershell to unlock the file manually.  I found these commands on this blog​.

To see the details of the file lock/confirm the file is locked:

$web = Get-SPWeb http://intranet.contoso.com 
$list = $web.Lists["DocLib"] 
$item = $list.GetItemById(2) 
​$file = $item.File 
$file

To impersonate the user who has the lock and unlock the file:

$web = Get-SPWeb http://intranet.contoso.com 
$list = $web.Lists["DocLib"] 
$item = $list.GetItemById(2) 
$file = $item.File 
$userId = $file.LockedByUser.ID 
$user = $web.AllUsers.GetByID($userId) 
$impSite= New-Object Microsoft.SharePoint.SPSite($web.Url, $user.UserToken); 
$impWeb = $impSite.OpenWeb(); 
$impList = $impWeb.Lists[$list.Title] 
$impItem = $impList.GetItemById($item.ID) 
$impFile = $impItem.File 
$impFile.ReleaseLock($impFile.LockId)​
May 17
How to Get First Day of Last Week for Report Parameter SSRS 2008 R2

I needed to make a report parameter that would apply conditional formatting to my tablix based on a date range of the previous week start and end dates.

Start Date of Last Week:

=DateAdd("d",-7,(DateAdd("d",-DatePart(DateInterval.WeekDay,Today,0,0)+1,Today)))​

End Date of Last Week:

=DateAdd("d",-1,(DateAdd("d",-DatePart(DateInterval.WeekDay,Today,0,0)+1,Today)))​
May 05
How to Get Month Name When You Only Have Month Number (SQL View)

I on​ly have the month's number and not a full date.  I need to use both the month's number and the name in a SSRS parameter.  (I sort by the number and display the name.  I then filter my dataset on the month number.)

Here's the trick!

SELECT distinct [MonthofYear], DateName(mm,DATEADD(mm,MonthofYear - 1,0)) as MonthName
FROM V_MyView
Order By MonthofYear

April 12
How to Change the Home Page URL on SharePoint 2010 Team Site

I have a SharePoint 2010 team site that I didn't want to use the "Wiki Home Page" option and didn't want to turn on publishing.  I simply wanted to change the default home page URL from http://site/default.aspx to http://site/pages/home.aspx.​  (This home page uses a tabbed interface for an app-like feeling.)

I found this post​ which provided the Powershell to make the change:

Add-PsSnapin Microsoft.SharePoint.PowerShell 

$w = get-spweb http://yoursite

$r = $w.RootFolder

$r.WelcomePage = "Pages/Home.aspx"

$r.Update()

$w.Dispose()

It worked beautifully!  Now, when using the breadcrumbs, or the Site Name as a link back to the home page of the site, it always goes to this home page.
March 30
Nintex Form Field Validation Expressions

I'm just learning Nin​tex Forms and found out that a SharePoint field control, such as a number field set to two decimals, comes over on the Nintex form as a Single Line Textbox control and doesn't respect the SharePoint field settings!  So, the user can type in alpha characters, 500 numbers after the decimal, etc.  Annoying!

So, here are some of my common expressions used in the Validations section of the Control Settings of the Single Line Textbox SharePoint field control:

NintexControlSettings.jpg

Currency

To show currency in ##.## format, 1-199 before the decimal and 2 digits after the decimal.

^([1][1-9][0-9]|[1-9][0-9]|[0-9])((\.)[0-9][0-9])$

Decimal

To show a number in #.## format where the decimal is optional, allowing 1-2 digits before the decimal and 1-2 digits after the decimal (optional).

^[1-9][0-9]{0,2}(?:\.[0-9]{​0,2})?$​

Days of the Month

To allow numbers 1-31 to be entered.

^(3[01]|[12][0-9]|[1-9])$​​

Valid Year

To allow a valid 4-digit year between 1900-2099.

^(?:(?:19|20)[0-9]{2})​​

Valid Zip Code

To allow 00000-99999 to be entered.

^\d{1,5}$

Number Range

To allow numbers 1-160 to be entered.

^([1-9]|[1-8][0-9]|9[0-9]|1[0-5][0-9]|160)$​

(It's easiest to use this Number Range Generator​. Just remember to include the carat (^) at the beginning and the dollar symbol ($) at the end.)

Here's a great reference​ for Regular Expressions that I used to build mine above.
​​​
February 28
Calculating Week Number in Calculated Field

I needed to calculated the week number based off the Created date.  

I found many blog and forum posts using the formula below, but it kept adding 5 weeks.  I think it had something do to with my regional settings ("Define Your Work Week")

=INT((Created-DATE(​YEAR(Created),1,1)+(TEXT(WEEKDAY(DATE(YEAR(Created),1,1)),"d")))/7)+1​

I did find this formula that worked!

​=INT((Created-DATE(YEAR(Created-WEEKDAY(Created-1)+4),1,3)+WEEKDAY(DATE(YEAR(Created-WEEKDAY(Created-1)+4),1,3))+5)/7)​

February 08
Formatting a Date Field in Nintex Form SQL Request Control

I needed to return a date in a SQL query using the Nintex Form SQL Request Control.  I can do this via a simple SQL query. However, the returned format is:

10/31/2016 12:0​0:00 AM

I need it to be 10/31/2016.

Yes, I can create a calculated control to format this SQL Request Control, but then I have to "hide" the control and only display the calculated control. What a pain!

I found that I can convert the date field in the SQL query to the format I need!​

SQL query before:

Select EnrollmentStartDate
V_ActiveSEParticipantEnrollment
Where ParticipantID='SQLID_Participant'

SQL query after:

Select convert (varchar, EnrollmentStartDate, 101) AS EnrollmentStartDate
From V_ActiveSEParticipantEnrollment
Where ParticipantID='SQLID_Participant'

​Both the Value and Display field in the SQL Request Control settings are "EnrollmentStartDate".

Here's the reference to the date formats used in the Convert command. (The number referenced after the field.)
December 23
Hide Green Plus Button on Inline Editing View

I want to hide the green "plus" button at the bottom of an inline editing view on a list.  In fact, I really want to use this view in a Nintex List View control.  So, even if I remove the icon via SharePoint Designer, the Nintex List View control still renders it. (I know...odd!)

GreenAddPlus.jpg
I found this forum post with a simple jquery/CSS solution that worked perfectly!  Just add this code into a Content Editor Web Part on the page (hide the web part).

<script

src="http://code.jquery.com/jquery-1.10.2.min.js"

type="text/javascript">

</script>

<style

type="text/css">

.ms-listviewtable

 img[alt='New']{

   display:none;

}

</style>

November 22
Run a Workflow on a List Via Powershell

Use this Powershell script to run a specific workflow on a specific list:

# URL of the Site

$web = Get-SPWeb -Identity "https://sharepointsrv/site1"

$manager = $web.Site.WorkFlowManager

# Name of the list

$list = $web.Lists["Shared Documents"]

# Name of the Workflow

$assoc = $list.WorkflowAssociations.GetAssociationByName("On Item Created","en-US")

$data = $assoc.AssociationData

$items = $list.Items

foreach($item in $items)

 {

 $wf = $manager.StartWorkFlow($item,$assoc,$data,$true)

 }

$manager.Dispose()

$web.Dispose()

#

I used to have to make a change to every list item (using Datasheet view) to force the "on update run the workflow".  However, sometimes this doesn't work if the item doesn't have all required fields completed. 

​Thanks to this blog post​ for this script. It worked like a charm for me!
1 - 10Next