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

 

 

.

12/18/2015

Test Post for the New Office Live Writer!

 

Google Blogger.com broke Microsoft Live Writer earlier in the year with an update to their login security. They then reversed the change and Live Writer users were back in business. Yea!

Then last week they broke it again, and said that it was final.  Boo!

Along comes a group of volunteers from Microsoft with an “open” release of Live Writer called Open Live Writer. At first it did not support the new Blogger security requirements, but as of yesterday it does! Hallelujah!

If you are a Live Writer fan then go take a look at this new version: http://openlivewriter.org/

image

 

What’s missing so far?

  • The Set Categories bar and options are missing. (But I can take care of this in the Blogger web site.)
  • Plug-ins. (I use a plug-in in Live Writer to format code. But I can still format things in the old Live Write and copy and paste as needed.
  • Spell checking! (The way I type, I really need this back!)
  • ??? (still testing – visit the project site: https://github.com/OpenLiveWriter/OpenLiveWriter )

 

.

12/12/2015

MVC: The controller for path '/' was not found or does not implement IController


Some error messages are no help at all!


While working on a Visual Studio 2013 MVC project I got this error:



When running in Debug mode Visual Studio reports:
An exception of type 'System.Web.HttpException' occurred in System.Web.dll but was not handled in user code.
Additional information: Execution of the child request failed. Please examine the InnerException for more information.

The inner exception: 
{System.Web.HttpException (0x80004005): The controller for path '/' was not found or does not implement IController.
   at System.Web.Mvc.DefaultControllerFactory.GetControllerInstance




A web search returns many possibilities for the error, but none that applied to my project. It turns out I had one of those "forest and trees" problems! I had typed Html.Action instead of Html.ActionLink in a Layouts view. In effect I was asking the layouts view to load a view that used the layouts view that then loaded the layouts view that loaded the view that used the layouts view… Yup, an endless loop.


The error message was not of much help and sent me on a wild goose chase. Once I realized what was going on I made one small edit and was back in business.



.

12/06/2015

Get short lists of PowerShell cmdlets

 

I write a lot of documentation and I’m always looking for ways to make lists of things easier to read. Long lists of PowerShell commands have always been a problem as they usually should be sorted by the noun. That’s easy enough, but still can consume a lot of space on paper, and still not be too readable, especially when I want to see all the things I can do with a “user”, a “group” or some other object where I have a lot of cmdlets with the same noun.

For example, there are 135 AD cmdlets on my machine. By default Get-Command orders them by verb. But what are all of things I can do with a "user" or "group"?

image

We can sort on the Noun property, but we still get 135 lines of output:

image

 

So here is my solution… and while I'm happy with the results, I think the script is kind of ugly.

Get-Command *-ad* | Group Noun | 
  foreach { $_.Group | 
    foreach -Begin { $x = @{ noun = $_.Group[0].Noun; verb = ""} } 
            -Process { $x.verb += $_.Verb + "," } 
            -End {$x.verb = $x.verb.substring(0,$x.verb.length-1); $x; } } | 
  sort {$_.noun} | select {$_.noun}, {$_.verb} | ft -AutoSize

image

And now I can see at a glance that I can Get, New, Remove and Set. (And not Add or Delete!)

image

 

.

12/03/2015

SharePoint: Generate a report of inactive sites and owners

This article is for SharePoint 2007, 2010, 2013 and 2016 on premises. (2007 users see the note at the end of the article.)

Cleaning up inactive sites is a common best practice administrator activity. Finding these sites and getting a list of who to contact can take a bit of work. Here's a little PowerShell script to generate a report of all inactive sites, their Site Collection Administrators and their Full Control users.

 

Inactive Site?

Each web has a property named LastItemModifiedDate that can be used as one criteria for site activity. I say "one criteria" as the site may not have had been updated in months, but users still visit the site and view the content every day. In the scripts below we check for the inactivity using a Where that tests against a calculated date:

Where { $_.LastItemModifiedDate -lt ((Get-Date).AddMonths(-9)) }

You can change the test date by using AddDays, AddMonths and AddYears with negative numbers to "go back in time". The example above looks for webs not updated in the last 9 months.

Note: The LastItemModifiedDate (and all other internal SharePoint dates) is in GMT. To convert to local time use ".ToLocalTime()".

image

 

Create a report…

The following script generates a report that lists each web, last updated date, Site Collection Administrators and Full Control users. Note that if you added an Active Directory group with Full Control, only the group name will be listed, not all of the member users.

image

Get-SPSite -Limit All | 
  Get-SPWeb -Limit All | 
  Where { $_.LastItemModifiedDate -lt ((Get-Date).AddMonths(-9)) } |
  foreach {
    # the URL
    ""   #blank line
    $_.url
    "  LastItemModifiedDate: " + $_.LastItemModifiedDate
    "  Web has unique permissions: " + $_.HasUniquePerm

    # the Site Collection Administrators
    " Site Collection Administrators:"
    foreach ($user in $_.SiteAdministrators)
    {      
       "  " + $user.DisplayName + " " + $user.UserLogin
    }

    # full control users
    " Full Control Users:"
    foreach ($user in $_.Users)
    {
       if ( $_.DoesUserHavePermissions($user,[Microsoft.SharePoint.SPBasePermissions]::FullMask) )      
       { 
         "  " + $user.DisplayName + " " + $user.UserLogin
       }
    }
  }

 

Create a customized SPWeb object for further pipelining…

If you would rather have an output that can be piped on to other cmdlets then use the following script. It adds a PowerShell NoteProperty to each SPWeb object named FullControlUsers can be accessed as if it was a built-in property.

Get-SPSite -Limit All | 
  Get-SPWeb -Limit All | 
  Where { $_.LastItemModifiedDate -lt ((Get-Date).AddMonths(-9)) } |
  foreach {
  
    $TTNusers = @();   #empty collection

    foreach ($user in $_.Users)
    {
       if ( $_.DoesUserHavePermissions($user,[Microsoft.SharePoint.SPBasePermissions]::FullMask) )      
       { 
         $TTNusers += $user;  # add to the collection
       }
    }

    # add the new property
    $_ | Add-Member -type NoteProperty -name FullControlUsers -value $TTNusers;

    # forward the modified SPWeb object on through the piepline.
    $_;

  } | 
  Select Url, SiteAdministrators, FullControlUsers 

image

Or maybe change the "Select" to "Format-List":

image

 

Performance Tip

If this script is run during business hours on a large farm you could impact your users. Consider adding a Start-Sleep cmdlet just after the foreach to insert a small delay between webs. But of course, that will make your script take longer to complete.

image

.

For SharePoint 2007

Replace:

Get-SPSite -Limit All | Get-SPWeb -Limit All |

With:

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Administration")
$webapp = [Microsoft.SharePoint.Administration.SPWebApplication]::Lookup("http://maxsp2013wfe")
$webapp.sites | Select -ExpandProperty AllWebs |

 

..

11/28/2015

SharePoint Content Type Inheritance

This article applies to SharePoint 2010, 2013 and 2016.

If you have worked around SharePoint for a while then you have heard the phrase "Everything is a list…". If everything is a list then everything should be an "item", right? Turns out that that is almost a fact. With the exception of only a handful of Content Types, they all inherit from"Item". In the end everything inherits from a base type named "System". The listing below is from a 2013 publishing site with a few extra features enabled to find as many Content Types as possible. The 2016 list is very similar, but is missing some of the Business Intelligence content types (Excel Services?).

A few examples:

  • Task <- Item <- System
  • Document <- Item <- System
  • Video <- System Media Collection <- Document Set <- Document Collection Folder <- Folder <- Item <- System

What does not inherit from Item?

  • Common Indicator Columns <- System  (hidden)
  • And the types that inherit from it:
    • Excel based Status Indicator <- Common Indicator Columns <- System
    • Fixed Value based Status Indicator <- Common Indicator Columns <- System
    • SharePoint List based Status Indicator <- Common Indicator Columns <- System
    • SQL Server Analysis Services based Status Indicator <- Common Indicator Columns <- System

 

    PowerShell to the rescue… again.

    To dump the hierarchy of Content Types I wrote a little PowerShell script that uses a recursive function. Just edit the URL to your site and you can get your list of Content Types.

    If you wanted to see the inheritance pattern another way, add the ID of the Content Type to your output, or just do a test like the following and note the pattern in the IDs:

      $web.ContentTypes | sort id | Select id, name

     

    The PowerShell script:

    function Get-CTypeParent ($ctype, $TTNstr)
    {
      if ($ctype.name -NE "System") {
       $TTNstr = $TTNstr + " <- " + $ctype.parent.name;
       $TTNstr = Get-CTypeParent $ctype.parent $TTNstr 
       }
      return $TTNstr;
    }
    
    $site = Get-SPSite http://yourserver/sites/yourSite
    $web = $site.RootWeb
    
    $web.ContentTypes | sort Group, Name | 
      group Group | 
        foreach { $_.Group  | 
                         foreach 
                           -Begin {"`n" + $_.Name} 
                           -Process { $str="  " + $_.Name ;  Get-CTypeParent $_ $str } 
                }
    

     

    The list of Content Types and their family history!

    This list is from SharePoint 2013. The 2016 list is very similar, but is missing some of the Business Intelligence content types (Excel Services?).

    _Hidden
      Administrative Task <- Task <- Item <- System
      Approval Workflow Task (en-US) <- SharePoint Server Workflow Task <- Workflow Task <- Task <- Item <- System
      Collect Feedback Workflow Task (en-US) <- SharePoint Server Workflow Task <- Workflow Task <- Task <- Item <- System
      Collect Signatures Workflow Task (en-US) <- SharePoint Server Workflow Task <- Workflow Task <- Task <- Item <- System
      Common Indicator Columns <- System
      Design File <- Document <- Item <- System
      Device Channel <- Item <- System
      Device Channel Mappings <- Document <- Item <- System
      Display Template <- Document <- Item <- System
      Display Template Code <- Display Template <- Document <- Item <- System
      Document Collection Folder <- Folder <- Item <- System
      DomainGroup <- Item <- System
      Health Analyzer Report <- Item <- System
      Health Analyzer Rule Definition <- Item <- System
      InfoPath Form Template <- Document <- Item <- System
      Office Data Connection File <- Document <- Item <- System
      Page Output Cache <- Item <- System
      PerformancePoint Base <- Item <- System
      PerformancePoint Monitoring Document Type <- Document <- Item <- System
      Person <- Item <- System
      Project Policy <- Item <- System
      Published Link <- Item <- System
      Publishing Approval Workflow Task (en-US) <- SharePoint Server Workflow Task <- Workflow Task <- Task <- Item <- System
      Reusable HTML <- Item <- System
      Reusable Text <- Item <- System
      RootOfList <- Folder <- Item <- System
      Rule <- Item <- System
      SharePoint Server Workflow Task <- Workflow Task <- Task <- Item <- System
      SharePointGroup <- Item <- System
      Signatures Workflow Task Deprecated <- SharePoint Server Workflow Task <- Workflow Task <- Task <- Item <- System
      System
      System Master Page <- Document <- Item <- System
      System Media Collection <- Document Set <- Document Collection Folder <- Folder <- Item <- System
      System Page <- Document <- Item <- System
      System Page Layout <- Document <- Item <- System
      Translation Package <- Document <- Item <- System
      Translation Status <- Document <- Item <- System
      Universal Data Connection File <- Document <- Item <- System
      User Workflow Document <- Document <- Item <- System
      Workflow History <- Item <- System
      Workflow Task <- Task <- Item <- System
      WorkflowServiceDefinition <- Item <- System
      WorkflowServiceSubscription <- Item <- Systemvi
     
    Business Intelligence
      Excel based Status Indicator <- Common Indicator Columns <- System
      Fixed Value based Status Indicator <- Common Indicator Columns <- System
      Report <- Document <- Item <- System
      Report Document <- Document <- Item <- System
      SharePoint List based Status Indicator <- Common Indicator Columns <- System
      SQL Server Analysis Services based Status Indicator <- Common Indicator Columns <- System
      Web Part Page with Status List <- Document <- Item <- System
     
    Community Content Types
      Category <- Item <- System
      Community Member <- Site Membership <- Item <- System
      Site Membership <- Item <- System
     
    Digital Asset Content Types
      Audio <- Rich Media Asset <- Document <- Item <- System
      Image <- Rich Media Asset <- Document <- Item <- System
      Rich Media Asset <- Document <- Item <- System
      Video <- System Media Collection <- Document Set <- Document Collection Folder <- Folder <- Item <- System
      Video Rendition <- Rich Media Asset <- Document <- Item <- System
     
    Display Template Content Types
      Control Display Template <- Display Template <- Document <- Item <- System
      Filter Display Template <- Display Template <- Document <- Item <- System
      Group Display Template <- Display Template <- Document <- Item <- System
      Item Display Template <- Display Template <- Document <- Item <- System
      JavaScript Display Template <- Document <- Item <- System
     
    Document Content Types
      Basic Page <- Document <- Item <- System
      Document <- Item <- System
      Dublin Core Columns <- Document <- Item <- System
      Form <- Document <- Item <- System
      Link to a Document <- Document <- Item <- System
      List View Style <- Document <- Item <- System
      Master Page <- Document <- Item <- System
      Master Page Preview <- Document <- Item <- System
      Picture <- Document <- Item <- System
      Web Part Page <- Basic Page <- Document <- Item <- System
      Wiki Page <- Document <- Item <- System
     
    Document Set Content Types
      Document Set <- Document Collection Folder <- Folder <- Item <- System
     
    Folder Content Types
      Discussion <- Folder <- Item <- System
      Folder <- Item <- System
      Summary Task <- Folder <- Item <- System
     
    Group Work Content Types
      Circulation <- Item <- System
      Holiday <- Item <- System
      New Word <- Item <- System
      Official Notice <- Item <- System
      Phone Call Memo <- Item <- System
      Resource <- Item <- System
      Resource Group <- Item <- System
      Timecard <- Item <- System
      Users <- Item <- System
      What's New Notification <- Item <- System
     
    List Content Types
      Announcement <- Item <- System
      Comment <- Item <- System
      Contact <- Item <- System
      East Asia Contact <- Item <- System
      Event <- Item <- System
      Issue <- Item <- System
      Item <- System
      Link <- Item <- System
      Message <- Item <- System
      Post <- Item <- System
      Reservations <- Event <- Item <- System
      Schedule <- Event <- Item <- System
      Schedule and Reservations <- Event <- Item <- System
      Task <- Item <- System
      Workflow Task (SharePoint 2013) <- Task <- Item <- System
     
    Page Layout Content Types
      Article Page <- Page <- System Page <- Document <- Item <- System
      Catalog-Item Reuse <- Page <- System Page <- Document <- Item <- System
      Enterprise Wiki Page <- Page <- System Page <- Document <- Item <- System
      Error Page <- Page <- System Page <- Document <- Item <- System
      Project Page <- Enterprise Wiki Page <- Page <- System Page <- Document <- Item <- System
      Redirect Page <- Page <- System Page <- Document <- Item <- System
      Welcome Page <- Page <- System Page <- Document <- Item <- System
     
    PerformancePoint
      PerformancePoint Dashboard <- PerformancePoint Base <- Item <- System
      PerformancePoint Data Source <- PerformancePoint Monitoring Document Type <- Document <- Item <- System
      PerformancePoint Filter <- PerformancePoint Base <- Item <- System
      PerformancePoint Indicator <- PerformancePoint Base <- Item <- System
      PerformancePoint KPI <- PerformancePoint Base <- Item <- System
      PerformancePoint Report <- PerformancePoint Base <- Item <- System
      PerformancePoint Scorecard <- PerformancePoint Base <- Item <- System
     
      
    Publishing Content Types
      ASP NET Master Page <- System Master Page <- Document <- Item <- System
      Html Master Page <- ASP NET Master Page <- System Master Page <- Document <- Item <- System
      Html Page Layout <- Page Layout <- System Page Layout <- Document <- Item <- System
      Page <- System Page <- Document <- Item <- System
      Page Layout <- System Page Layout <- Document <- Item <- System
     
    Special Content Types
      Unknown Document Type <- Document <- Item <- System

     

    The List Sorted By Ancestor

    Change the last line of the script to the following and you can see another pattern in the inheritance.

    $web.contenttypes | sort group, name | group group | foreach { $_.Group  | foreach -begin {"`n" + $_.Name} -process { $str="  " + $_.name ;  Get-CTypeParent $_ $str } }

    System ->   Item
    System -> Item ->   Announcement
    System -> Item ->   Circulation
    System -> Item ->   Comment
    System -> Item ->   Contact
    System -> Item ->   Device Channel
    System -> Item ->   Document
    System -> Item ->   DomainGroup
    System -> Item ->   East Asia Contact
    System -> Item ->   Event
    System -> Item ->   Folder
    System -> Item ->   Health Analyzer Report
    System -> Item ->   Health Analyzer Rule Definition
    System -> Item ->   Holiday
    System -> Item ->   Issue
    System -> Item ->   Link
    System -> Item ->   Message
    System -> Item ->   New Word
    System -> Item ->   Official Notice
    System -> Item ->   Page Output Cache
    System -> Item ->   PerformancePoint Base
    System -> Item ->   Person
    System -> Item ->   Phone Call Memo
    System -> Item ->   Post
    System -> Item ->   Published Link
    System -> Item ->   Resource
    System -> Item ->   Resource Group
    System -> Item ->   Reusable HTML
    System -> Item ->   Reusable Text
    System -> Item ->   Rule
    System -> Item ->   SharePointGroup
    System -> Item ->   Task
    System -> Item ->   Timecard
    System -> Item ->   Users
    System -> Item ->   What's New Notification
    System -> Item ->   Workflow History
    System -> Item ->   WorkflowServiceDefinition
    System -> Item ->   WorkflowServiceSubscription
    System -> Item -> Document ->   Basic Page
    System -> Item -> Document ->   Design File
    System -> Item -> Document ->   Device Channel Mappings
    System -> Item -> Document ->   Display Template
    System -> Item -> Document ->   Dublin Core Columns
    System -> Item -> Document ->   Form
    System -> Item -> Document ->   InfoPath Form Template
    System -> Item -> Document ->   JavaScript Display Template
    System -> Item -> Document ->   Link to a Document
    System -> Item -> Document ->   List View Style
    System -> Item -> Document ->   Master Page
    System -> Item -> Document ->   Master Page Preview
    System -> Item -> Document ->   Office Data Connection File
    System -> Item -> Document ->   PerformancePoint Monitoring Document Type
    System -> Item -> Document ->   Picture
    System -> Item -> Document ->   Report Document
    System -> Item -> Document ->   Rich Media Asset
    System -> Item -> Document ->   System Master Page
    System -> Item -> Document ->   System Page
    System -> Item -> Document ->   System Page Layout
    System -> Item -> Document ->   Translation Package
    System -> Item -> Document ->   Translation Status
    System -> Item -> Document ->   Universal Data Connection File
    System -> Item -> Document ->   Unknown Document Type
    System -> Item -> Document ->   User Workflow Document
    System -> Item -> Document ->   Wiki Page
    System -> Item -> Document -> Basic Page ->   Web Part Page
    System -> Item -> Document -> Display Template ->   Control Display Template
    System -> Item -> Document -> Display Template ->   Display Template Code
    System -> Item -> Document -> Display Template ->   Filter Display Template
    System -> Item -> Document -> Display Template ->   Group Display Template
    System -> Item -> Document -> Display Template ->   Item Display Template
    System -> Item -> Document -> PerformancePoint Monitoring Document Type ->   PerformancePoint Data Source
    System -> Item -> Document -> Rich Media Asset ->   Audio
    System -> Item -> Document -> Rich Media Asset ->   Image
    System -> Item -> Document -> Rich Media Asset ->   Video Rendition
    System -> Item -> Document -> System Master Page ->   ASP NET Master Page
    System -> Item -> Document -> System Master Page -> ASP NET Master Page ->   Html Master Page
    System -> Item -> Document -> System Page ->   Page
    System -> Item -> Document -> System Page -> Page ->   Article Page
    System -> Item -> Document -> System Page -> Page ->   Catalog-Item Reuse
    System -> Item -> Document -> System Page -> Page ->   Enterprise Wiki Page
    System -> Item -> Document -> System Page -> Page ->   Error Page
    System -> Item -> Document -> System Page -> Page ->   Redirect Page
    System -> Item -> Document -> System Page -> Page ->   Welcome Page
    System -> Item -> Document -> System Page -> Page -> Enterprise Wiki Page ->   Project Page
    System -> Item -> Document -> System Page Layout ->   Page Layout
    System -> Item -> Document -> System Page Layout -> Page Layout ->   Html Page Layout
    System -> Item -> Event ->   Reservations
    System -> Item -> Event ->   Schedule
    System -> Item -> Event ->   Schedule and Reservations
    System -> Item -> Folder ->   Discussion
    System -> Item -> Folder ->   Document Collection Folder
    System -> Item -> Folder ->   RootOfList
    System -> Item -> Folder ->   Summary Task
    System -> Item -> Folder -> Document Collection Folder ->   Document Set
    System -> Item -> Folder -> Document Collection Folder -> Document Set ->   System Media Collection
    System -> Item -> Folder -> Document Collection Folder -> Document Set -> System Media Collection ->   Video
    System -> Item -> PerformancePoint Base ->   PerformancePoint Dashboard
    System -> Item -> PerformancePoint Base ->   PerformancePoint Filter
    System -> Item -> PerformancePoint Base ->   PerformancePoint Indicator
    System -> Item -> PerformancePoint Base ->   PerformancePoint KPI
    System -> Item -> PerformancePoint Base ->   PerformancePoint Report
    System -> Item -> PerformancePoint Base ->   PerformancePoint Scorecard
    System -> Item -> Task ->   Administrative Task
    System -> Item -> Task ->   Workflow Task
    System -> Item -> Task ->   Workflow Task (SharePoint 2013)
    System -> Item -> Task -> Workflow Task ->   PSWApprovalTask
    System -> Item -> Task -> Workflow Task ->   SharePoint Server Workflow Task
    System -> Item -> Task -> Workflow Task -> SharePoint Server Workflow Task ->   Approval Workflow Task (en-US)
    System -> Item -> Task -> Workflow Task -> SharePoint Server Workflow Task ->   Collect Feedback Workflow Task (en-US)
    System -> Item -> Task -> Workflow Task -> SharePoint Server Workflow Task ->   Collect Signatures Workflow Task (en-US)
    System -> Item -> Task -> Workflow Task -> SharePoint Server Workflow Task ->   Publishing Approval Workflow Task (en-US)
    System -> Item -> Task -> Workflow Task -> SharePoint Server Workflow Task ->   Signatures Workflow Task Deprecated

     


     

    System ->   Item
    System -> Item ->   Announcement
    System -> Item ->   Circulation
    System -> Item ->   Comment
    System -> Item ->   Contact
    System -> Item ->   Device Channel
    System -> Item ->   Document
    System -> Item ->   DomainGroup
    System -> Item ->   East Asia Contact
    System -> Item ->   Event
    System -> Item ->   Folder
    System -> Item ->   Health Analyzer Report
    System -> Item ->   Health Analyzer Rule Definition
    System -> Item ->   Holiday
    System -> Item ->   Issue
    System -> Item ->   Link
    System -> Item ->   Message
    System -> Item ->   New Word
    System -> Item ->   Official Notice
    System -> Item ->   Page Output Cache
    System -> Item ->   PerformancePoint Base
    System -> Item ->   Person
    System -> Item ->   Phone Call Memo
    System -> Item ->   Post
    System -> Item ->   Published Link
    System -> Item ->   Resource
    System -> Item ->   Resource Group
    System -> Item ->   Reusable HTML
    System -> Item ->   Reusable Text
    System -> Item ->   Rule
    System -> Item ->   SharePointGroup
    System -> Item ->   Task
    System -> Item ->   Timecard
    System -> Item ->   Users
    System -> Item ->   What's New Notification
    System -> Item ->   Workflow History
    System -> Item ->   WorkflowServiceDefinition
    System -> Item ->   WorkflowServiceSubscription
    System -> Item -> Document ->   Basic Page
    System -> Item -> Document ->   Design File
    System -> Item -> Document ->   Device Channel Mappings
    System -> Item -> Document ->   Display Template
    System -> Item -> Document ->   Dublin Core Columns
    System -> Item -> Document ->   Form
    System -> Item -> Document ->   InfoPath Form Template
    System -> Item -> Document ->   JavaScript Display Template
    System -> Item -> Document ->   Link to a Document
    System -> Item -> Document ->   List View Style
    System -> Item -> Document ->   Master Page
    System -> Item -> Document ->   Master Page Preview
    System -> Item -> Document ->   Office Data Connection File
    System -> Item -> Document ->   PerformancePoint Monitoring Document Type
    System -> Item -> Document ->   Picture
    System -> Item -> Document ->   Report Document
    System -> Item -> Document ->   Rich Media Asset
    System -> Item -> Document ->   System Master Page
    System -> Item -> Document ->   System Page
    System -> Item -> Document ->   System Page Layout
    System -> Item -> Document ->   Translation Package
    System -> Item -> Document ->   Translation Status
    System -> Item -> Document ->   Universal Data Connection File
    System -> Item -> Document ->   Unknown Document Type
    System -> Item -> Document ->   User Workflow Document
    System -> Item -> Document ->   Wiki Page
    System -> Item -> Document -> Basic Page ->   Web Part Page
    System -> Item -> Document -> Display Template ->   Control Display Template
    System -> Item -> Document -> Display Template ->   Display Template Code
    System -> Item -> Document -> Display Template ->   Filter Display Template
    System -> Item -> Document -> Display Template ->   Group Display Template
    System -> Item -> Document -> Display Template ->   Item Display Template
    System -> Item -> Document -> PerformancePoint Monitoring Document Type ->   PerformancePoint Data Source
    System -> Item -> Document -> Rich Media Asset ->   Audio
    System -> Item -> Document -> Rich Media Asset ->   Image
    System -> Item -> Document -> Rich Media Asset ->   Video Rendition
    System -> Item -> Document -> System Master Page ->   ASP NET Master Page
    System -> Item -> Document -> System Master Page -> ASP NET Master Page ->   Html Master Page
    System -> Item -> Document -> System Page ->   Page
    System -> Item -> Document -> System Page -> Page ->   Article Page
    System -> Item -> Document -> System Page -> Page ->   Catalog-Item Reuse
    System -> Item -> Document -> System Page -> Page ->   Enterprise Wiki Page
    System -> Item -> Document -> System Page -> Page ->   Error Page
    System -> Item -> Document -> System Page -> Page ->   Redirect Page
    System -> Item -> Document -> System Page -> Page ->   Welcome Page
    System -> Item -> Document -> System Page -> Page -> Enterprise Wiki Page ->   Project Page
    System -> Item -> Document -> System Page Layout ->   Page Layout
    System -> Item -> Document -> System Page Layout -> Page Layout ->   Html Page Layout
    System -> Item -> Event ->   Reservations
    System -> Item -> Event ->   Schedule
    System -> Item -> Event ->   Schedule and Reservations
    System -> Item -> Folder ->   Discussion
    System -> Item -> Folder ->   Document Collection Folder
    System -> Item -> Folder ->   RootOfList
    System -> Item -> Folder ->   Summary Task
    System -> Item -> Folder -> Document Collection Folder ->   Document Set
    System -> Item -> Folder -> Document Collection Folder -> Document Set ->   System Media Collection
    System -> Item -> Folder -> Document Collection Folder -> Document Set -> System Media Collection ->   Video
    System -> Item -> PerformancePoint Base ->   PerformancePoint Dashboard
    System -> Item -> PerformancePoint Base ->   PerformancePoint Filter
    System -> Item -> PerformancePoint Base ->   PerformancePoint Indicator
    System -> Item -> PerformancePoint Base ->   PerformancePoint KPI
    System -> Item -> PerformancePoint Base ->   PerformancePoint Report
    System -> Item -> PerformancePoint Base ->   PerformancePoint Scorecard
    System -> Item -> Task ->   Administrative Task
    System -> Item -> Task ->   Workflow Task
    System -> Item -> Task ->   Workflow Task (SharePoint 2013)
    System -> Item -> Task -> Workflow Task ->   PSWApprovalTask
    System -> Item -> Task -> Workflow Task ->   SharePoint Server Workflow Task
    System -> Item -> Task -> Workflow Task -> SharePoint Server Workflow Task ->   Approval Workflow Task (en-US)
    System -> Item -> Task -> Workflow Task -> SharePoint Server Workflow Task ->   Collect Feedback Workflow Task (en-US)
    System -> Item -> Task -> Workflow Task -> SharePoint Server Workflow Task ->   Collect Signatures Workflow Task (en-US)
    System -> Item -> Task -> Workflow Task -> SharePoint Server Workflow Task ->   Publishing Approval Workflow Task (en-US)
    System -> Item -> Task -> Workflow Task -> SharePoint Server Workflow Task ->   Signatures Workflow Task Deprecated

     

     

     

     

     

    11/23/2015

    SharePoint 2013: Hide JSLink from Team Members

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

     

    Let's start with a couple "did you knows"…

    Did you know:

    • All users with Edit and Contribute permission levels can edit the home page of your site?
    • The same users can edit or delete any page in the Site Pages library.?
    • They can also edit the web parts on that page? And use advanced options like JS Link?

    As part of your SharePoint governance or best practices you may want to limit who can use some of the more advanced customization features of SharePoint 2013 and 2016. JS Link, is after all, JavaScript programming and it can cause issues for daily support and the upgrade to future versions of SharePoint.

    Before we get into locking down just JS Link, let's address the "did you knows". You may want to think about changing the permissions of Site Pages, Site Assets and a few other libraries to read only for all users except for Site Owners. Those libraries really should not be open for all to edit.

     

    About JS Link

    JS Link is a really cool technology introduced with SharePoint 2013 to let us customize web parts, views and list forms without "un-ghosting" pages using SharePoint Designer. It lets us create a JavaScript text file, store it in a library, and then link it to a web part or a form. If you are a developer, you can also use JS Link with Site Columns and Site Content Types. One of the benefits of JS Link is that the customization file can be created once, stored in a library and then be linked into many web parts and forms. When you need a change in the future, you only need to edit a single JavaScript file and not dozens or hundreds of web parts.

    For web parts, JS Link is added in the Miscellaneous section of the web part properties panel.

    image

     

    Hiding JS Link

    As SharePoint does not have a "switch" where we can just turn off the use of JS Link, we will need to come up with a CSS or JavaScript solution. If you add the following CSS to your master page (lots of ways to do this) then the JS Link box will be hidden.

    <style type="text/css">
      input[id$="_JSLink_EDITOR"] {
        display:none;
      }
      label[for$="_JSLink_EDITOR"] {
        display:none;
      }
    </style>
    

     

    While we are at it, you may also want to hide the XSL Link option too:

    <style type="text/css">
      input[id$="_JSLink_EDITOR"] {
        display:none;
      }
      label[for$="_JSLink_EDITOR"] {
        display:none;
      }
      input[id$="_XslLink_EDITOR"] {
        display:none;
      }
      label[for$="_XslLink_EDITOR"] {
        display:none;
      }
    </style>
    

     

    But what about the Site Owner?

    If you want some users to still be able to edit the JS Link and XSL Link options then we can give those back using a SharePoint Security Trimmed Control. You just need to pick a permission that is unique that that group of users such as Add and Customize Pages. In the example below we take away JS Link from all users, and then give it back to select users.

    <style type="text/css">
      input[id$="_JSLink_EDITOR"] {
        display:none;
      }
      label[for$="_JSLink_EDITOR"] {
        display:none;
      }
      input[id$="_XslLink_EDITOR"] {
        display:none;
      }
      label[for$="_XslLink_EDITOR"] {
        display:none;
      }
    </style>
    <Sharepoint:SPSecurityTrimmedControl runat="server" PermissionsString="AddAndCustomizePages"> <!-- Let owners and designers see the JSLink options --> <style type="text/css"> input[id$="_JSLink_EDITOR"] { display:inline; } label[for$="_JSLink_EDITOR"] { display:inline; } input[id$="_XslLink_EDITOR"] { display:inline; } label[for$="_XslLink_EDITOR"] { display:inline; } </style> </SharePoint:SPSecurityTrimmedControl>

     

    .

    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.