Showing posts with label SharePoint Development. Show all posts
Showing posts with label SharePoint Development. Show all posts

10/15/2018

SharePoint Calculated Columns and Validation Formulas – The Book!


Available on Amazon!


It only took me a year… and it grew from a little booklet to over 200 pages… but its finally done!

Bought the book? Post any questions, bugs, typos and suggestions to this blog post!


Everything you need to know about SharePoint formulas for SharePoint 2010 to 2019 and SharePoint Online / Office 365!

image

This book is for the SharePoint “power user” who needs a better understanding of how SharePoint formulas work, where they don’t work, and how they are created. While at first glance SharePoint formulas appear to be simple calculations, they are both quite powerful and have weird limitations. In this book we will explore the basics of creating Calculated Columns and Validation formulas with some boring details, and over one hundred examples. We also explore workarounds for many of the limitations by using SharePoint Designer workflows and a few tricks!

 

Over 100 Examples!

A how-to book of formulas would not be too useful without a few examples. I've been collecting these for years. They've come from classroom questions, forum questions, and my own SharePoint sites. Now they are all in one place…

  • · Over 60 Calculated Columns examples
  • · Over 30 Column Validation examples
  • · 11 List/Library Item Validation examples
    (and every one of the Column Validation examples can be used here.)
  • · 7 Calculated Column Default Values examples
  • · 15 Workflow “workarounds” for things SharePoint formulas can’t do

Scroll on down for a complete list of the examples.


Who is this book for?

Anyone who creates and customizes lists and libraries. These include: SharePoint on premise Farm Administrators, Office 365 SharePoint administrators, Site Collection Administrators, Site Owners, Power users, and Developers.

 

Where are formulas used in SharePoint?

  • Calculated column formulas derive data from other columns in the same list item. These can be simple calculations and text manipulations, or complex Excel-style formulas.
  • Column validation formulas are used to create custom validations for user entered data. These can be used to make sure that "quantities" are not negative and vacation requests are for dates in the future.
  • Column default formulas, while very limited, can auto-fill columns with a date 30 days in the future or a message based on the month or day of the week the item was added.
  • List / Library validation formulas are used to check the values from multiple columns to verify the relationship between two or more columns. Examples include making sure a task start date is before the task end date, or to make sure an entry has a "price per pound" or a "price each", but not both.


Workflow Workarounds?

SharePoint formulas only work with a few column types while SharePoint workflows can access just about any column type. So, with a little workflow work your formulas can make these columns available to SharePoint formulas. There's over fifty pages of workflow workaround tips:

  • Workaround for People and Groups
  • Getting Data from a Person or Group Column
  • Getting a User’s Manager
  • Workaround for the SUBSTITUTE Function
  • Workaround for Getting View Totals from Calculated Columns.
  • Workaround for Adding Images to a Column
  • Workaround for Multiple Lines of Text
  • Workaround for Lookup Columns
  • Lookup a Single Item (No checkboxes)
  • Extract Several Lookup Columns into a Single Line of Text
  • Workaround for Multivalued Choice Columns
  • Counting Items Selected in a Multivalued Column
  • Workaround for Managed Metadata columns
  • Workaround for Single Valued Managed Metadata Columns
  • Workaround for Multi Valued Managed Metadata Columns
  • Workarounds for Attachments

 

Table of Contents

  • Read Me First
  • Tips for Formulas
  • Calculated Columns
  • Calculated Column Examples
  • Calculated Default Columns
  • Column Validation Formulas
  • Column Validation Examples
  • List/Library Item Validation
  • List/Library Item Validation Examples
  • Other Forms of Validation
  • Workflow Workarounds
  • Error Messages


Examples:

Calculated Column Examples:·

·        Fun stuff that may not work for you:

o   Add HTML to a Calculated Column

o   Add icons or pictures to a Calculated Column

o   Building an Address (String Concatenation)

o   Create a Bar Chart Column

·        Columns for Views

o   View Filtering on a Calculated Column

o   Group by Year

o   Group by Month and Year

o   Group by Year Plus Month

o   Grouping on an Algorithm

·        Numbers

o   Adding Leading Zeros to a Number

o   Scientific Notation

o   Roman Numerals

·        The IF Function and Boolean Logic

o   Calculating a Discount using Nested IFs

o   Working Around Nested IF Limits

o   Convert from State Codes to State Names

o   ANDs and ORs - Approve if all approved, or reject if any one rejects

·        Test for values

o   Testing for a Range of Dates

o   Testing for Empty Columns

o   Testing for Errors

·        Summing and Counting Columns

o   Counting Yes/No Columns

o   Average

o   MIN and MAX

·        More on Numbers

o   Raise a Number to a Power

o   Rounding Numbers

·        Working with Text

o   Combining Text Columns

o   Display First Name and Last Name in a Single Column

o   Creating Title Capitalization

·        Return the Right Data Type!

·        Dates

o   Subtracting Dates

o   Finding a Date One Year in the Future

o   Change Date Formatting

o   Fiscal Year

o   Week Number

o   Day of the Year

o   First Day of the Current Month

o   First Day of the Next Month

o   Last Day of the Current Month

o   Last Day of the Previous Month

o   Last Day of the Next Month

o   Third Tuesday of a Month

o   Skipping Weekend Days

o   Next Workday “X” Days in the Future

o   Simple Solutions for 5, 10, 15 Working Days in the Future

o   Solution for Any Number of Working Days in the Future

o   Working Days

o   Number of Working Hours Between Two Dates

·        Formatting and Conversions

o   Formatting Numbers

o   Adding Text to Numbers

o   Adding Special Symbols (¥, £, etc.) to TEXT() Number Formats

o   Converting Numbers to Fractions

o   Financial Calculations

·        Random Numbers and Messages

o   Creating Random Numbers (Using NOW)

o   Creating Random Messages (using CHOOSE)

·        A Calculated Task Status

·        Great Circle Distance from Longitude and Latitude

·        Simplify a Workflow by Using a Calculated Column

Column Validation Examples

·        Limit time for user updates.

·        Boolean operations

o   Examples Using “OR”

o   Examples Using “AND”

o   Examples Using “AND” and “OR”

o   Examples Using “NOT”

·        Testing for Empty Columns

o   Yes/No

o   Dates

o   ISBLANK()

·        Working with Dates

o   Date Must be in the Future

o   Date Must be in the Future “x” Days

o   Date Must be in the Future “x” Days and not on a Weekend

o   Test Against a Specified Date

o   Date Must be Between Now and the End of the Current Year

o   Date Must be Within the Next 30 days

o   Date Must be the Last Day of the Month

o   Date Must be the First Day of the Month

o   Date Must be the Third Tuesday of the Month

o   Date Can Only be a Weekday

o   Date Can Only be Monday or Wednesday

o   Entered Date Must be for this Year

o   Date Must be Current Or Next Month Only

·        Working with Numbers

o   Testing for Numbers in Custom Increments

o   Limit the Number of Decimal Places Entered

·        Working with Text

o   Testing for Text Length

o   Testing for a Valid State/Province (or other code)

o   Test to Require an Uppercase or Lowercase Letter 

·        Examples Using Pattern Matching

o   Must start with an "a" or "A" and the third character must be a "c" or "C"

o   Match a Phone Number Pattern of xxx-xxx-xxxx

o   Match a Phone Number Pattern of xxx-xxx-xxxx and Limit the Length

o   Match a Phone Number and Make Sure Only Digits Have Been Used


And many more!

1/22/2018

SharePoint Search Weirdness – Part 5: Search REST API Ignores Duplicates


A continuation of the "Search Weirdness" series!


If you are a developer, or a SharePoint 2013 workflow designer, then you probably have used the SharePoint Search REST API. Did you know that you are probably not getting all of the results expected?

Here’s a typical REST search for the word “sharepoint”:

http://yourSiteUrl/_api/search/query?querytext='sharepoint'

Or if you would like to be a little more selective:

http://yourSiteUrl/_api/search/query?querytext='sharepoint'&selectproperties='Title,Author'&refinementfilters='fileExtension:equals("docx")'

or you would like to return more than the default number of items:

http://yourSiteUrl/_api/search/query?querytext='sharepoint'&selectproperties='Title,Author'&refinementfilters='fileExtension:equals("docx")'&rowlimit=1000


The problem with the above searches is that Search thinks some of your results are duplicates, so it removed them! To solve this problem just add this to your URL:

    &trimduplicates=true

Your search URLs then might look like these:

http://yourSiteUrl/_api/search/query?querytext='sharepoint'&trimduplicates=true

http://yourSiteUrl/_api/search/query?querytext='sharepoint'&selectproperties='Title,Author'&refinementfilters='fileExtension:equals("docx")'&trimduplicates=true

http://yourSiteUrl/_api/search/query?querytext='sharepoint'&selectproperties='Title,Author'&refinementfilters='fileExtension:equals("docx")'&rowlimit=1000&trimduplicates=true


.

12/23/2017

No More HTML in SharePoint Calculated Columns!

Update: Here's a workaround using a workflow: http://techtrainingnotes.blogspot.com/2018/01/adding-html-to-sharepoint-columns-color.html


Just in case you missed it:
“Some users have added HTML markup or script elements to calculated fields. This is an undocumented use of the feature, and we will block the execution of custom markup in calculated fields in SharePoint Online from June 13, 2017 onwards. The June 2017 Public Update (PU) and later PUs will make blocking a configurable option for on-premises use in SharePoint Server 2016 and SharePoint Server 2013.”
https://support.microsoft.com/en-us/help/4032106/handling-html-markup-in-sharepoint-calculated-fields

So, no more of this:
   image
Or this:
    =REPT("<img src='http://yourPath/yourImage.GIF' style='border-style:none'/>",[Value])
  image

8/11/2016

Using Relative URLs in SharePoint 2013 Workflow Calls

 

(For SharePoint 2013, 2016 and SharePoint Online.)

It's generally a good idea to use relative URLs when creating something that you will want to use in more than one place. While not real obvious, you can easily do this in SharePoint 2013 workflow web service calls.

Absolute URL:
   http://yourServerName/sites/yourSiteName/_api/web

Relative URL:
   /sites/yourSiteName/_api/web

What we would like to have in a workflow web service call:
   _api/web

Steps:

  1. After adding your Call HTTP Web Service action, click “this”
    image.
  2. Click the "" button to open the String Builder dialog.
     image
    1. Click the Add or Change Lookup button.
    2. For Data source select Workflow Context.
    3. For Field from source select Current Site URL.
    4. Immediately after the lookup place holder (i.e. no spaces) type the rest of the URL for the web service call:
         _api/web

      image
    5. Click OK.
  3. Continue with web service call action configuration…

 

As you can probably guess… I’m working on a new class that includes workflows!

.

1/03/2016

“Unable to display this Web Part” after XSLT Customization

The following applies to SharePoint 2013, 2016 and SharePoint Online.

 

The Error

“Unable to display this Web Part. To troubleshoot the problem, open this Web page in a Microsoft SharePoint Foundation-compatible HTML editor such as Microsoft SharePoint Designer. If the problem persists, contact your Web server administrator.”

image

The above error shows up in SharePoint 2013 and later when doing multi-level grouping with Data Form Web Parts. With the removal of many of the design features from SharePoint Designer 2013, I doubt there are too many people creating new XSLT customization. But if you are upgrading from 2010 or trying to implement a 2010 style customization then you many run into this error.

 

The Cause and the Fix

If you dig into the error logs you will find that this is reported as “Error while executing web part: System.StackOverflowException”. Turns out though that it is a timeout of the XSLT parser and has been around for quite a while. The fix is pretty easy, if you are on premises, just run a tiny PowerShell script from the SharePoint Management Shell.

image

$farm = Get-SPFarm
$farm.XsltTransformTimeOut = 10
$farm.Update()

Some of the articles say to increase it from the default of 1 second to 5 seconds. In my test environment I typically needed to increase it to 10 seconds. If you monitor the CPU on the server you will see that at least on lab-type virtual machines that a page load where you have this issue does put quite a load on the CPU.

SharePoint Online?  No joy for you! It appears that the default is 1 second, and you can’t change it.

 

There’s been a number of articles on the topic, mostly in the SP 2010 world:

http://thechriskent.com/tag/xslttransformtimeout/

http://blogs.msdn.com/b/joerg_sinemus/archive/2012/03/07/xslt-and-timeout-problem-when-transforming-runs-more-than-one-second.aspx

and many more: http://www.bing.com/search?q=xslttransformtimeout+sharepoint

 

.

12/30/2015

SharePoint – Adding Dropdown Menus without the Publishing Feature

 

The following works in SharePoint 2013, 2016 (beta 2) and SharePoint Online.

 

One of the common reasons to enable the Publishing Feature was to get the Navigation page so you could have dropdowns in the Top Link bar. Turns out that in 2013 and later you can do this without the Publishing Feature.

The Trick!

The trick is drag and drop. Starting with SharePoint 2013 you have an “EDIT LINKS” button on the page. (No Top Link Bar or Navigation page needed!)

image

When you click EDIT LINKS you can add a new item to the menu by clicking the (+) button.

image

Then there’s the trick! Drag the new link just under the parent link. (I’ll drag this one under the “Subsite1” link.)

image

image

Click Save and now you have dropdowns!

image

 

What you don’t get…

The Publishing feature Navigation page lets you select options like Open in New Window and Audience selection.

But if all you need are some dropdowns…

 

.

12/22/2015

SharePoint JS Link Context Object Details

This article applies to SharePoint 2013, 2016 and SharePoint Online.

This article is a work in progress!

 

It seems I’ve been writing a lot of JS Link lately and I’m always playing a guessing game with the data available via the “context” parameter. If you know where to look, you can find this info right in the page! Just because you can find it does not mean you know what it is or how to use it. This article is my collection of notes “so far”. I will be back to update as I have time and learn more!

 

Context

Each of the functions you write for JS Link will be passed a “context” object as a parameter. From this object you can retrieve properties about the current list, current list item and other objects. In the rest of the article are examples of the data returned from the context object.

There are several child context objects that you may be working with: (documented below)

  • Context.CurrentItem for a list item
  • Context.CurrentItem.somefile (results vary based on field type)
  • Context.CurrentItem.AssignedTo
  • Context.CurrentFieldSchema
  • Context.ListData  <—This represents the rows of data in the web part.
  • Context.ListSchema
  • Context.ListSchema.PropertyBag
  • Context.Templates
  • Context.Templates.Fields
  • Context.BasePermissions

By context, I am referring to the object passed in to a JavaScript function registered by SPClientTemplates.TemplateManager.RegisterTemplateOverrides and not the object passed to RegisterTemplateOverrides. (Too many JS Link code examples on the web name the object passed to RegisterTemplateOverrides as “ctx”, “context” or other names that imply context.)

(function () { 

  // do all of the setup work...
  var overrides = {};
  overrides.Templates = {}; 

  // define the web part view
  overrides.Templates.Header = "<b>Cool Web Part</b> <ul>";
  overrides.Templates.Footer = "</ul> Check back for updates!";
  overrides.Templates.Item =
function(ctx) {return "<li>" + ctx.CurrentItem.Title + "</li>"}; // register the override SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrides); })();

 

 

List Data

JS Link passes the context data as a parameter to your functions. When working with other JavaScript code you often need to access data about the web parts on the page. In SharePoint 2013, 2016 and SharePoint Online, metadata about the content of list web parts is embedded in the page’s JavaScript as JSON data. This data is preloaded into variables with names based on the web part names. Examples: WPQ3ListData, WPQ4ListData, etc. You can access these variables directly, or use ListData property of the “context” variable passed into JS Link functions.

To discover the metadata about a list, i.e. the Title, URL, etc., search for “new ContextInfo”. 

Ways of finding the list items data:

  • In your browser visit the list or library page and use the browser’s View Source feature to see the JSON formatted data that describes the list and list data. Search for “ListData =”.
  • Use the F12 Tools to access the global ListData variables:  WPQ3ListData, WPQ4ListData, etc.
  • Run some custom JavaScript to dump the context objects as nice HTML tables.

 

Using View Source

An example of the View Source where I searched for “ListData” and found the fields in the ListData section for one of the web parts in the page:

image

 

The View Source approach is a quick way to discover:

  • The internal names of fields. For example, you can’t find “% complete” here but you can find “PercentComplete”.
  • That some items are simple data types and some are collections or objects that require extra work to access.
    clip_image002
    To access the Priority property all you need to use is ctx.CurrentItem.Priority. To access AssignedTo you won’t be able to just use ctx.CurrentItem.AssignedTo. Note the square bracket (“[“) in the data. This indicates that this is a collection of objects, so at a minimum you will need to use ctx.CurrentItem.AssignedTo[0] to retrieve the first object. Also note the curly brackets (“{“) that indicate an object. To use this data you will need to specify the object’s property like this: ctx.CurrentItem.AssignedTo[0].title.

 

 

The Context Object

This list has the sample results from a context object for a task list. (Comments in blue.) Note that many of the properties are themselves objects or collections objects.

Property

Value

library only

listBaseType

0

 

listTemplate

171

This is the template ID or the Registration ID for the template used to create the list. 171 is for “Tasks (2013 version)”. For a list of IDs see: http://techtrainingnotes.blogspot.com/2015/02/sharepoint-2013-list-and-library.html

 

listName

{E7ADB1A8-5C1C-437F-B946-369431601856}

GUID. Unique ID for the list.

 

view

{437CC0EA-EC27-4AE9-AD44-70762F4DF28E}

GUID. Unique ID for the list.

 

listUrlDir

/sites/yourSite/Lists/Tasks

URL to the list.

 

HttpPath

https://yourDomain.com/sites/yourSite/_vti_bin/owssvr.dll?CS=65001

URL to the OWSSVR.dll remote procedure call. Returns XML. Example: https://yourDomain.com/sites/yourSite/_vti_bin/owssvr.dll?CS=65001&Cmd=Display&List={BD415E20-AC5F-41DA-BAC9-F054C4764A2}

 

HttpRoot

https://yourDomain.com/sites/yourSite

URL to the site (SPWeb) that contains the list.

 

serverUrl

null

 

imagesPath

/_layouts/15/images/

Server folder for icons and images.

 

PortalUrl

null

 

RecycleBinEnabled

1

 

enteringGridMode

false

 

inGridMode

false

 

isWebEditorPreview

0

 

rootFolderForDisplay

null

 

isPortalTemplate

null

 

isModerated

false

 

recursiveView

false

 

displayFormUrl

https://yourDomain.com/sites/yourSite/_layouts/15/listform.aspx?PageType=4&ListId=%7BE7ADB1A8%2D5C1C%2D437F%2DB946%2D369431601856%7D

Link to the View Item form. (.ASPX or InfoPath form)

 

editFormUrl

https://yourDomain.com/sites/yourSite/_layouts/15/listform.aspx?PageType=6&ListId=%7BE7ADB1A8%2D5C1C%2D437F%2DB946%2D369431601856%7D

Link to the Edit Item form. (.ASPX or InfoPath form)

 

newFormUrl

https://yourDomain.com/sites/yourSite/_layouts/15/listform.aspx?PageType=8&ListId=%7BE7ADB1A8%2D5C1C%2D437F%2DB946%2D369431601856%7D&RootFolder=

Link to the New Item form. (.ASPX or InfoPath form)

 

ctxId

27

 

CurrentUserId

9

This is the Site Collection ID of the user and will be different in each Site Collection.

 

isForceCheckout

false

 

EnableMinorVersions

false

 

ModerationStatus

0

 

verEnabled

0

 

isVersions

0

 

WorkflowsAssociated

false

 

ExternalDataList

false

 

HasRelatedCascadeLists

1

 

CascadeDeleteWarningMessage

null

 

ContentTypesEnabled

true

 

SendToLocationName

 

 

SendToLocationUrl

 

 

StateInitDone

false

 

TotalListItems

null

 

CurrentSelectedItems

null

 

LastSelectableRowIdx

null

 

SelectAllCbx

null

 

TableCbxFocusHandler

null

 

TableMouseoverHandler

null

 

onItemSelectionChangedHandlers

 

 

wpq

WPQ2

This is part of the web part’s name (“WebPartWPQ2”) and prefix for other related variables such as WPQ2ListData and WPQ2SchemaData.

 

Templates

[object Object]

See “Context.Templates” below.

 

ListData

[object Object]

See “Context.ListData” below.

ctx.ListData[idOfCurrentItem] is the same as ctx.CurrentItem.

 

ListSchema

[object Object]

See “Context.ListSchema” below.

 

BaseViewID

1

 

ListTemplateType

171

This is the template ID or the Registration ID for the template used to create the list. 171 is for “Tasks (2013 version)”. For a list of IDs see: http://techtrainingnotes.blogspot.com/2015/02/sharepoint-2013-list-and-library.html

 

existingServerFilterHash

undefined

 

noGroupCollapse

true

Only present if view Grouping is enabled and “By default, show groupings” is set to “Collapsed”.

 

NavigateForFormsPages

true

 

BasePermissions

[object Object]     

See Context.BasePermissions below.

 

CurrentUserIsSiteAdmin

true

 

IsAppWeb

false

 

AllowGridMode

true

 

rootFolder

 

 

viewTitle

All Tasks

Title of the current view.

 

NoScriptEnabled

false

 

OfficialFileName

 

 

OfficialFileNames

 

 

WriteSecurity

1

 

SiteTitle

JS Link Demo 1

 

ListTitle

Tasks

 

isXslView

true

 

IsClientRendering

true

 

RegionalSettingsTimeZoneBias

300

Contains the bias, in minutes, that a time zone differs from Coordinated Universal Time (UTC), or the bias, in minutes, that standard time or daylight saving time for a time zone differs from UTC. 

 

NewWOPIDocumentEnabled

True

Lib

NewWOPIDocumentUrl

/sites/yourSite/_layouts/15/CreateNewDocument.aspx?SaveLocation=%2Fsites%2FyourSite%2FShared%20Documents&DefaultItemOpen=1

Lib

AllowCreateFolder

true

Lib

SiteTemplateId

1

 

bInitialRender

true

 

ListDataJSONItemsKey

Row

 

ControlMode

4

 

SiteClientTag

0$$16.0.4622.1221

 

CurrentLanguage

1033

Locale IDs Assigned by Microsoft. 1033 = US English. See: https://msdn.microsoft.com/en-us/goglobal/bb964664.aspx

 

CurrentCultureName

en-US

 

CurrentUICultureName

en-US

 

OnPreRender


JS Link function defined for current web part.

 

OnPostRender

function(){var a=document.getElementById("cbxSelectAllItems"+b.ctxId),c="ontouchstart"in document.documentElement&&!IsSupportedChromeOnWin()?"touchstart":"click";$addHandler(a,c,function(){a.checked=!a.checked;if(ListModule.Settings.SupportsItemSelection){WriteDocEngagementLog("Documents_SelectAllClick","OneDrive_SelectAllClick");ToggleAllItems(c,a,b.ctxId)}})},function(){setTimeout(j,0)}

JS Link function defined for current web part. The above example is a “default” function.

 

canDragUpload

true

 

RenderView

function g(a){return b(a,"View")}

 

RenderHeader

function l(a){return b(a,"Header")}

 

RenderBody

function n(a){return b(a,"Body")}

 

RenderFooter

function j(a){return b(a,"Footer")}

 

RenderGroups

function k(a){if(a==null||a.ListData==null)return"";var b=null;if(a.Templates!=null)b=a.Templates.Group;var k=a.ListData,j=k[f(a)],h="";if(j==null){if(typeof b=="string"||typeof b=="function"){a.CurrentGroupIdx=0;a.CurrentGroup=k;a.CurrentItems=k[c(a)];h+=CoreRender(b,a);a.CurrentItems=null;a.CurrentGroup=null}return h}for(var i=0;i<j.length;i++){var g=j[i],e=d(a,g,"Group");if(e==null||e==""){if(b==null||b=={})return"";if(typeof b=="string"||typeof b=="function")e=b;if(e==null||e==""){var l=g.GroupType;e=b[l]}}if(e==null||e=="")continue;a.CurrentGroupIdx=i;a.CurrentGroup=g;a.CurrentItems=g[c(a)];h+=CoreRender(e,a);a.CurrentGroup=null;a.CurrentItems=null}return h}

 

RenderItems

function m(a){if(a==null||a.ListData==null)return"";var g=null;if(a.Templates!=null)g=a.Templates.Item;var p=a.ListData,e=a.CurrentItems;if(e==null)e=typeof a.CurrentGroup!="undefined"?a.CurrentGroup[c(a)]:null;if(e==null){var l=p[f(a)];e=typeof l!="undefined"?l[c(a)]:null}if(e==null)return"";for(var j="",h=0;h<e.length;h++){var i=e[h],b=d(a,i,"Item");if(b==null||b==""){if(g==null||g=={})return"";if(typeof g=="string"||typeof g=="function")b=g;if(b==null||b==""){var o=i.ContentType;b=g[o]}}if(b==null||b=="")continue;a.CurrentItemIdx=h;a.CurrentItem=i;if(typeof a.ItemRenderWrapper=="string")a.ItemRenderWrapper==SPClientRenderer.ParseTemplateString(a.ItemRenderWrapper,a);if(typeof a.ItemRenderWrapper=="function"){var k=a.ItemRenderWrapper,m={TemplateFunction:k,Operation:"ItemRenderWrapper"},n=function(){return k(CoreRender(b,a),a,b)};j+=CallFunctionWithErrorHandling(n,a,"",m)}else j+=CoreRender(b,a);a.CurrentItem=null}return j}

 

RenderFields

function i(a){if(a==null||a.Templates==null||a.ListSchema==null||a.ListData==null)return"";var f=a.CurrentItem,b=a.ListSchema.Field,d=a.Templates.Fields;if(f==null||b==null||d==null)return"";var c="";for(var g in b)c+=e(a,b[g]);return c}

 

RenderFieldByName

function h(a,c){if(a==null||a.Templates==null||a.ListSchema==null||a.ListData==null||c==null||c=="")return"";var d=a.CurrentItem,b=a.ListSchema.Field,g=a.Templates.Fields;if(d==null||b==null||g==null)return"";if(typeof SPClientTemplates!="undefined"&&spMgr!=null&&a.ControlMode==SPClientTemplates.ClientControlMode.View)return spMgr.RenderFieldByName(a,c,d,a.ListSchema);for(var f in b)if(b[f].Name==c)return e(a,b[f]);return""}

 

heroId

idHomePageNewItem

 

CurrentItem

[object Object]

See “Context.CurrentItem” below.

 

CurrentItemIdx

0

 

CurrentFieldSchema

[object Object]

See “Context.FieldSchema” below.

 

allowedSuiteExtensionFileTypes

bmp,chm,gif,htm,html,jpeg,jpg,pdf,png,psd,tif,txt,wma,wmv,xml,zip

Lib

 

 

Context.CurrentItem

These properties are retrieved from the CurrentItem property of the Context. This example is for a Task list. Properties unique to a task list are marked “(Task list field.)”.

 

Property

Value

outlineLevel

1

For task lists. Top level task = 1. First child = 2, etc.

ID

5

Internal generated list item ID. Starts at 1. This is the ID column in a view.

PermMask

0x7fffffffffffffff

Permissions Mask. See https://msdn.microsoft.com/en-us/library/cc704409.aspx and http://sympmarc.com/2009/02/03/permmask-in-sharepoint-dvwps/

FSObjType

0

ContentType

Task

Also see ContentTypeId below.

Checkmark

No

PercentComplete

45.5 %  

(Task list field.)

Returns a string with a percent sign.

PercentComplete.

0.455000000000000 

(Task list field.)

Returns a number between 0 and 1.

Due the the “.” in the property name you will need to use the index notation to retrieve this: ctx.CurrentItem['PercentComplete.'].

Title

Task99

List/library item title.

FileLeafRef

5_.000                  Mydocument.docx

Name in path for item. (File name for library documents.)

Created_x0020_Date.ifnew

Returns “1” if the “New” icon should be displayed.

FileRef

/sites/demosite/Lists/Tasks/5_.000
/sites/demosite/Documents/Mydocument.docx

Relative path to item.

File_x0020_Type

docx

File extension for library item.

File_x0020_Type.mapapp

undefined

HTML_x0020_File_x0020_Type.File_x0020_Type.mapcon

 

HTML_x0020_File_x0020_Type.File_x0020_Type.mapico

 

ContentTypeId

0x0108001C2144D361847C438854B157E203AB3E

DueDate


(Task list field.)

DueDate.FriendlyDisplay

undefined

(Task list field.)

See “Modified.FriendlyDisplay”.)

AssignedTo

[object Object]

Returns a collection of users, even if only one. You will need to index the collection. “ctx.CurrentItem.AssignedTo[0]” See Context.CurrentItem.AssignedTo below.

Priority

(2) Normal

(Task list field.)

Status

Not Started

(Task list field.)

Modified

11/18/2015 6:47 PM

Modified.FriendlyDisplay

undefined

Due the the “.” in the property name you will need to use the index notation to retrieve this: ctx.CurrentItem['Modified.FriendlyDisplay']. This property only returns “codes” that represent friendly dates. Display the date using GetRelativeDateTimeString(ctx.CurrentItem["Modified.FriendlyDisplay"]) to display “4 minutes ago” (instead of “1|0|3|5”) or “October 26” (instead of “0|October 26”).

_ModerationStatus

Pending

Content Approval text value of status. Property is only available if Content Approval is enabled. 

_ModerationStatus.

2

Content Approval numeric value of status. Property is only available if Content Approval is enabled. Approved=0, Rejected=1, Pending=2. Due to the “.” in the name you will need to use indexer access:  ctx.CurrentItem[“_ModerationStatus.”]

firstRow

true

Returns “true” for the first row, otherwise returns “undefined”. 

 

Context.CurrentItem.field for a Most Columns

For most columns the data is just returned as a string. Example: ctx.CurrentItem.Modified.

 

Context.CurrentItem.field for a Hyperlink Columns

Hyperlink columns are represented by two fields: fieldname and fieldname.desc Example: ctx.CurrentItem.ProductPicture and ctx.CurrentItem["ProductPicture.desc"] (Note that fields with dots must be accessed with using index notation.)

 

Context.CurrentItem.field for a Lookup Column

Lookup columns are returned as a collection of objects. (It may be a multiple choice column.) It must be accessed using an indexer: ctx.CurrentItem.TestLookup[0].

Property

Value

lookupId

2

lookupValue

Sales Department

isSecretFieldValue

false

 

Context.CurrentItem.field for a Managed Metadata Column

Managed Metadata columns are returned as objects. Example: ctx.CurrentItem.ToyCategory.Label

Property

Value

__type

TaxonomyFieldValue:#Microsoft.SharePoint.Taxonomy

Label

Boats

TermID

6eb29e02-8be0-4544-b2a7-d5d9fb2ea4f2

 

 

Context.CurrentItem (for the document library item)

 

Property

Value

ID

1

PermMask

0x7fffffffffffffff

Permissions Mask. See https://msdn.microsoft.com/en-us/library/cc704409.aspx and http://sympmarc.com/2009/02/03/permmask-in-sharepoint-dvwps/

FSObjType

0

HTML_x0020_File_x0020_Type

 

UniqueId

{AE945D21-B2CD-4C32-A7E4-B45D51C45F0D}

ProgId

 

File_x0020_Type

xlsx

File_x0020_Type.mapapp

undefined

HTML_x0020_File_x0020_Type.File_x0020_Type.mapcon

(Returns the object used to open a document in Office. “SharePoint.OpenDocuments”)

HTML_x0020_File_x0020_Type.File_x0020_Type.mapico

(Returns the icon for the file type. Example: icdocx.png)

serverurl.progid

(Example: 1https://yourDomain.com/sites/yourSite/Shared Documents/Event budget.xlsx?d=wae945d21b2cd4c32a7e4b45d51c45f0d )

ServerRedirectedEmbedUrl

https://yourDomain.com/sites/yourSite/_layouts/15/WopiFrame.aspx?sourcedoc={ae945d21-b2cd-4c32-a7e4-b45d51c45f0d}&action=interactivepreview

File_x0020_Type.progid

undefined

File_x0020_Type.url

undefined

FileRef

/sites/yourSite/Shared Documents/Event budget.xlsx

Relative path to the file.

FileLeafRef

Event budget.xlsx

Name in path for item. (File name for library documents.)

CheckoutUser

 

CheckedOutUserId

 

IsCheckedoutToLocal

0

Created_x0020_Date.ifnew

(Returns “1” if the “New” icon should be displayed)

ContentTypeId

0x010100DE3AED5D38F22748B9EA70FF971BAAB7

Modified

11/16/2015 7:56 PM

Modified.FriendlyDisplay

undefined

Editor

[object Object]

Title

This is the title for the budget file

Title property

firstRow

true

Returns “true” for the first row, otherwise returns “undefined”. 

 

Context.CurrentItem.AssignedTo

This is a collection. You will need to access using an indexer. Example ctx.CurrentItem.AssignedTo[0]. To retrieve a user property: ctx.CurrentItem.AssignedTo[0].title

Property

Value

 

id

12

This is the Site Collection ID of the user and will be different in each Site Collection.

value

Sam Conklin

title

Sam Conklin

email

samc@microsmith.onmicrosoft.com

sip

samc@microsmith.onmicrosoft.com

picture

https://microsmith-my.sharepoint.com:443/User%20Photos/Profile%20Pictures/samc_microsmith_onmicrosoft_com_MThumb.jpg

jobTitle

IT Manager

department

IT

 

 

 

Context.CurrentFieldSchema

This example is for the Modified date column and is not currently a complete list.

Property

Value

Name

Modified

FieldType

DateTime

RealFieldName

Modified

DisplayName

Modified

ID

28cf69c5-fa48-462a-b5cd-27b6f9d2bd5f

ReadOnly

TRUE

“ReadOnly” is only in the property list when the field is read only. I.e., you will not see “ReadOnly=FALSE”.

role

DateTime

ariaLabel

Modified

Type

DateTime

AllowGridEditing

FALSE

“AllowGridEditing” is only in the property list when the value is FALSE.

counter

3

FieldTitle

Modified

css

ms-cellstyle ms-vb2

fieldRenderer

your custom JS Link code is here

 

 

Context.ListData

Property

Value

Row

[object Object]

FirstRow

1

FolderPermissions

0x7fffffffffffffff

LastRow

1

FilterLink

?

ForceNoHierarchy

 

HierarchyHasIndention

 

 

Context.ListSchema

Property

Value

 

Field

[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]  (one object per field.)

 

LCID

1033

Locale IDs Assigned by Microsoft. 1033 = US English. See: https://msdn.microsoft.com/en-us/goglobal/bb964664.aspx

 

Userid

9

 

PagePath

/sites/yourSite/Lists/Tasks/AllItems.aspx

 

ShowWebPart

 

 

View

{437CC0EA-EC27-4AE9-AD44-70762F4DF28E}

 

RootFolderParam

View={437cc0ea-ec27-4ae9-ad44-70762f4df28e}&

 

FieldSortParam

 

 

HttpVDir

https://yourDomain.com/sites/yourSite

 

IsDocLib

 

 

UIVersion

15

 

NoListItem

There are no items to show in this view of the "Tasks" list.

 

NoListItemHowTo

To add a new item, click "New".

 

DefaultItemOpen

1

 

ForceCheckout

0

 

Direction

none

 

UseParentHierarchy

1

List

ParentHierarchyDisplayField

LinkTitle

List

TabularView

1

 

EffectivePresenceEnabled

1

 

PresenceAlt

No presence information

 

UserDispUrl

/sites/yourSite/_layouts/15/userdisp.aspx

 

SelectedID

-1

 

ListRight_AddListItems

1

 

FolderRight_AddListItems

1

 

InplaceSearchEnabled

1

 

HasTitle

1

Lib

StrikeThroughOnCompletedEnabled

1

List

RenderViewSelectorPivotMenu

True

 

ViewSelectorPivotMenuOptions

JSON representing the view selector menu

 

RenderSaveAsNewViewButton

True

 

Toolbar

Standard

 

PropertyBag

[object Object]

List

 

Context.ListSchema.PropertyBag 

(This is empty in a document library and is likely to be different for each list/library type.)

Property

Value

vti_hassubdirs

true

vti_listbasetype

0

vti_listrequirecheckout

false

vti_dirlateststamp

11/18/2015 11:59:25 PM

vti_replid

rid:{313BBBC4-BF57-4406-B24B-23B089C0217A}

vti_rtag

rt:313BBBC4-BF57-4406-B24B-23B089C0217A@00000000256

vti_isbrowsable

true

vti_listservertemplate

171

This is the template ID or the Registration ID for the template used to create the list. 171 is for “Tasks (2013 version)”. For a list of IDs see: http://techtrainingnotes.blogspot.com/2015/02/sharepoint-2013-list-and-library.html

vti_docstoretype

1

vti_listenableminorversions

false

vti_level

1

vti_isscriptable

false

vti_isexecutable

false

vti_docstoreversion

256

vti_listenablemoderation

false

vti_foldersubfolderitemcount

0

vti_listtitle

Tasks

vti_metainfoversion

1

vti_folderitemcount

1

vti_timelastmodified

11/18/2015 11:47:55 PM

vti_nexttolasttimemodified

11/18/2015 11:47:38 PM

vti_parentid

{415EA0AD-179C-4267-A90D-1BC43E9EB261}

vti_candeleteversion

true

vti_listenableversioning

false

vti_listname

{E7ADB1A8-5C1C-437F-B946-369431601856}

vti_etag

"{313BBBC4-BF57-4406-B24B-23B089C0217A},256"

vti_timecreated

11/17/2015 12:37:02 AM

 

 

Context.Templates

Property

Value

 

View

function RenderViewTemplate(a){var b=a.RenderHeader(a);b+=a.RenderBody(a);b+=a.RenderFooter(a);return b}

Header

function(b,e){  … lots of code here … }

Body

function(a){  … lots of code here … }

Footer

 

Group

function RenderItemTemplateDefault(a){return a!=null&&typeof a.RenderItems=="function"?a.RenderItems(a):""}

Item

function RenderFieldTemplateDefault(a){return a!=null&&typeof a.RenderFields=="function"?a.RenderFields(a):""}

Fields

[object Object]   (See Context.Templates.Fields below.) 

 

Context.Templates.Fields

This is a property of Context.Templates. The actual properties return depend on your list. The following is for a task list.

Property

Value

Checkmark

function RenderFieldValueDefault(a){return a!=null&&a.CurrentFieldValue!=null?a.CurrentFieldValue.toString():""}

LinkTitle

function RenderFieldValueDefault(a){return a!=null&&a.CurrentFieldValue!=null?a.CurrentFieldValue.toString():""}

DueDate

function RenderFieldValueDefault(a){return a!=null&&a.CurrentFieldValue!=null?a.CurrentFieldValue.toString():""}

AssignedTo

function RenderFieldValueDefault(a){return a!=null&&a.CurrentFieldValue!=null?a.CurrentFieldValue.toString():""}

PercentComplete

function percentComplete(ctx) { var x = ctx.CurrentItem[ctx.CurrentFieldSchema.Name].replace(" ",""); return '<div class="ms-progress-meter"><div class="ms-progress-meter-inner" style="width: ' + x +';"></div></div>' }    ß This is an example of a custom JS Link template in use.

Priority

function RenderFieldValueDefault(a){return a!=null&&a.CurrentFieldValue!=null?a.CurrentFieldValue.toString():""}

Status

function RenderFieldValueDefault(a){return a!=null&&a.CurrentFieldValue!=null?a.CurrentFieldValue.toString():""}

Modified

function RenderFieldValueDefault(a){return a!=null&&a.CurrentFieldValue!=null?a.CurrentFieldValue.toString():""}

 

Context.BasePermissions

This is a property of the Context object.

Property

Value

ManageLists

true

ManagePersonalViews

true

OpenItems

true

 

 

.

Note to spammers!

Spammers, don't waste your time... all posts are moderated. If your comment includes unrelated links, is advertising, or just pure spam, it will never be seen.