SharePoint 2013: Using WPQ2FormCtx to read list item information

SharePoint 2013 has an object called WPQ2FormCtx which holds plenty of useful information about the List and List Item in List pages like DisplayForm.aspx, EditForm.aspx and NewForm.aspx. I needed to know whether versioning is enabled in a list in the displayform of a list item. 
I did not want to write any JavaScript object model code to check that. Since display form already has Version History button which is either enabled or disabled based on whether versioning is enabled or not; I thought that this information must be available out of the box. I opened IE developer tools and started looking for this information. 
I found WPQ2FormCtx object and surprisingly it contains lots of useful information. WPQ2FormCtx.ListAttributes contains information about the list. Here I found EnableVersioning property as can be seen in the screenshot:

List Attributes

It also has ListData and ListSchema properties. ListData contains the data of the fields whereas ListSchema has the information about the type of fields. Here is the screenshot of ListData.

List Data

Similarly, it has several other important properties like ItemAttributes, ItemContentTypeId, ItemContentTypeName and even WebAttributes which contains information about the parent web object.

profile for Nadeem Yousuf at SharePoint Stack Exchange, Q&A for SharePoint enthusiasts

+