Json Context Helpers

This is a stub example and needs expanding to show usage of the p3context object

Summary

To make developing code with ShUIE easier, and to make it more powerful... it occurred to us that you'd want to know a bit about the context of the page you were on.

There are many basic questions that come up when developing ShUIE customisations:
  • What site are we on?
  • What subweb are we on?
  • Is this page associated to a List?
  • If we are associated to a List, what Fields exist?
  • For the Fields, what are the basic attributes of each Field?
  • Who is the currently logged on user?
  • Is the current user a site or web admin?

To answer these questions ShUIE renders some Json into every page that gives a subset of the information provided by the SPContext.Current object that is available within the WebControl.

The context object

The context object is rendered as Json into every page, and is available to all ShUIE customisations.

Note: The context object is NOT rendered if no customisations are active for this context.

The context object looks different for pretty much every page, but the name of it and the available properties remain constant.

Examples

The best way to show you what information you have available to you within your scripts is to show you what you're getting for free.

Note: In these examples, repetitive information such as Arrays of Lists and Fields have been trimmed to only show one instance, however it is likely that such Arrays will have many entries.

The context on a MOSS EPM Portal Home Page:
var p3context = {
    "CurrentList":
    {
        "AllowRssFeeds":true, 
        "Author":
        {
            "Name":"System Account", 
            "Email":"", 
            "Notes":"", 
            "IsSiteAdmin":false, 
            "RegionalSettings":null
        }, 
        "BaseTemplate":850, 
        "BaseType":1, 
        "CanReceiveEmail":false, 
        "ContentTypes":
        {
        }, 
        "ContentTypesEnabled":true, 
        "Created":"7/24/2008 8:59:53 AM", 
        "DefaultContentApprovalWorkflowId":"00000000-0000-0000-0000-000000000000", 
        "DefaultItemOpen":0, 
        "DefaultViewID":"ad2599d9-6362-4dae-b601-a0d202383938", 
        "DefaultViewImageUrl":"/_layouts/images/dlicon.png", 
        "DefaultViewTitle":"All Documents", 
        "DefaultViewUrl":"/Pages/Forms/AllItems.aspx", 
        "Description":"This system library was created by the Publishing feature to store pages that are created in this site.", 
        "Direction":"none", 
        "EmailAlias":null, 
        "EnableVersioning":true, 
        "Folders":
        {
        }, 
        "ForceCheckout":true, 
        "ID":"94a4afbf-c8d1-4595-a917-88c480ac13b4", 
        "ImageUrl":"/_layouts/images/itdl.gif", 
        "ItemCount":1, 
        "LastItemModifiedDate":"8/13/2008 11:14:13 AM", 
        "MobileDefaultViewUrl":"", 
        "OnQuickLaunch":false, 
        "Ordered":false, 
        "TemplateFeatureId":"22a9ef51-737b-4ff2-9346-694633fe4416", 
        "Title":"Pages", 
        "Version":41
    }, 
    "Fields":
    [
        {
            "AuthoringInfo":null, 
            "CanToggleHidden":false, 
            "DefaultValue":null, 
            "Description":"", 
            "Direction":"none", 
            "DisplaySize":null, 
            "FieldReferences":
            [
                "FileRef"
            ], 
            "Filterable":false, 
            "FromBaseType":true, 
            "Id":"105f76ce-724a-4bba-aece-f81f2fce58f5", 
            "InternalName":"ServerUrl", 
            "ReadOnlyField":true, 
            "Reorderable":false, 
            "Required":false, 
            "Scope":"/Pages", 
            "StaticName":"ServerUrl", 
            "Title":"Server Relative URL", 
            "TypeAsString":"Computed"
        }
    ], 
    "FormMode":"Display", 
    "IsDesignTime":false, 
    "ItemId":1, 
    "Lists":
    [
        {
            "BaseTemplate":105, 
            "BaseType":0, 
            "DefaultViewID":"349e2872-fd70-4c66-b534-1118aaeaf49a", 
            "DefaultViewImageUrl":"/_layouts/images/contacts.png", 
            "DefaultViewTitle":"All contacts", 
            "DefaultViewUrl":"/Lists/Contacts/AllItems.aspx", 
            "Description":"Create a contacts list when you want to manage information about people that your team works with such as customers or partners. You can share information between your contacts list and Windows SharePoint Services-compatible contacts programs.", 
            "ID":"96a6c430-879a-4659-8b25-6dfc47968bda", 
            "ImageUrl":"/_layouts/images/itcontct.gif", 
            "ItemCount":0, 
            "OnQuickLaunch":false, 
            "Title":"Contacts"
        }
    ], 
    "Site":
    {
        "HostName":"p3uk64p12", 
        "ID":"9a143128-e2c2-4a8f-ba03-0c9a8b1a6ed5", 
        "LastContentModifiedDate":"11/17/2008 2:06:30 PM", 
        "Owner":
        {
            "Name":"P3UK64P12\\Administrator", 
            "Email":"", 
            "Notes":"", 
            "IsSiteAdmin":true, 
            "RegionalSettings":null
        }, 
        "Port":80, 
        "PortalName":null, 
        "PortalUrl":null, 
        "Protocol":"http:", 
        "ServerRelativeUrl":"/", 
        "Url":"http://p3uk64p12"
    }, 
    "Web":
    {
        "AllProperties":
        {
            "vti_categories":"Business Competition Expense\\ Report Goals/Objectives Ideas In\\ Process Miscellaneous Planning Schedule Travel VIP Waiting", 
            "_reportinggallerytemplateid":"f8bb6ac2-00d6-4b1b-8bbe-71a3a4ed0c06", 
            "vti_createdassociategroups":"3;4;5", 
            "vti_defaultlanguage":"en-us", 
            "__SiteColDocumentsListId":"4923cce6-aba7-46ec-a513-a038cdabd8e9", 
            "SRCH_ENH_FTR_URL":"/searchcenter/Pages", 
            "__IncludeSubSitesInNavigation":"True", 
            "vti_approvallevels":"Approved Rejected Pending\\ Review", 
            "__ImagesListId":"461c358c-f4b9-4924-9912-511d330421d5", 
            "_SmtReportsListId":"609beed3-f83a-4bcd-99ce-4fd4f50e4f67", 
            "vti_associategroups":"5;4;3;6;7;8;9;10;11;14", 
            "__CacheProfileListId":"718e9cb5-2ef5-4c12-aedb-83544811a2c6", 
            "vti_usernames":"", 
            "NavigationPropertiesSet":"True", 
            "_VarRelationshipsListId":"64af3973-7cba-4a31-a72c-7d91bc8070ad", 
            "_reportinggallerymetadataid":"2fbb866c-2550-4efc-aaf1-822f2684a9a4", 
            "__DocumentsListId":"c622fb35-c150-42c5-97e2-2d4364c8cd3f", 
            "_VarLabelsListId":"d97659af-7e45-47df-93de-e2b735f53513", 
            "DefaultSiteDirectorySiteId":"9a143128-e2c2-4a8f-ba03-0c9a8b1a6ed5", 
            "_ReusableContentListId":"061ab8f2-fc30-4c86-988a-24f921140b2f", 
            "vti_associatevisitorgroup":"4", 
            "vti_extenderversion":"12.0.0.6219", 
            "__PublishingFeatureActivated":"True", 
            "vti_associateownergroup":"3", 
            "__SiteColImagesListId":"42eef0e0-b911-4553-8e3f-d4d4561c4d70", 
            "EnforceNewListingForSites":"false", 
            "__PagesListId":"94a4afbf-c8d1-4595-a917-88c480ac13b4", 
            "vti_associatemembergroup":"5", 
            "SiteDirectoryEntryRequirements":"SiteDirectoryCatsOptional", 
            "DefaultSiteDirectoryWebId":"be4dee29-02cb-4703-ba29-7a234bf494de"
        }, 
        "Author":
        {
            "Name":"P3UK64P12\\Administrator", 
            "Email":"", 
            "Notes":"", 
            "IsSiteAdmin":true, 
            "RegionalSettings":null
        }, 
        "Created":"7/24/2008 8:57:28 AM", 
        "CurrencyLocaleID":1033, 
        "CurrentUser":
        {
            "Name":"System Account", 
            "Email":"", 
            "Notes":"", 
            "IsSiteAdmin":true, 
            "RegionalSettings":null
        }, 
        "Features":
        {
        }, 
        "ID":"cfa180ad-b4ce-4ad7-94f0-ad8b79d5caa6", 
        "IsRootWeb":true, 
        "Language":1033, 
        "LastItemModifiedDate":"11/17/2008 12:29:21 PM", 
        "Locale":"English (United States)", 
        "Name":"", 
        "Navigation":
        {
            "UseShared":false
        }, 
        "PublicFolderRootUrl":null, 
        "QuickLaunchEnabled":true, 
        "RegionalSettings":
        {
            "LocaleId":1033, 
            "CalendarType":1, 
            "Time24":false, 
            "AdjustHijriDays":0, 
            "Collation":25, 
            "AlternateCalendarType":0, 
            "ShowWeeks":false, 
            "FirstWeekOfYear":0, 
            "WorkDays":62, 
            "WorkDayStartHour":480, 
            "WorkDayEndHour":1020, 
            "FirstDayOfWeek":0
        }, 
        "ServerRelativeUrl":"/", 
        "Title":"EPM Portal", 
        "Url":"http://p3uk64p12", 
        "UserIsSiteAdmin":true, 
        "UserIsWebAdmin":true, 
        "WebTemplate":"SPS", 
        "WebTemplateId":20
    }
};

The context on a Project Server PWA Home page:
var p3context = {
    "CurrentList":null, 
    "Fields":null, 
    "FormMode":"Invalid", 
    "IsDesignTime":false, 
    "ItemId":0, 
    "Lists":
    [
        {
            "BaseTemplate":101, 
            "BaseType":1, 
            "DefaultViewID":"033a8ac4-557d-4f70-9ec5-6c6a3b2aa313", 
            "DefaultViewImageUrl":"/_layouts/images/dlicon.png", 
            "DefaultViewTitle":"All Documents", 
            "DefaultViewUrl":"/PWA/Shared Documents/Forms/AllItems.aspx", 
            "Description":"Share a document with the team by adding it to this document library.", 
            "ID":"74080ab3-0bc0-4712-a099-e8733df30640", 
            "ImageUrl":"/_layouts/images/itdl.gif", 
            "ItemCount":2, 
            "OnQuickLaunch":true, 
            "Title":"Shared Documents"
        }
    ], 
    "Site":
    {
        "HostName":"p3uk64p12", 
        "ID":"f43bea00-92a4-443b-8630-479d0e2cd548", 
        "LastContentModifiedDate":"12/1/2008 4:41:20 PM", 
        "Owner":
        {
            "Name":"P3UK64P12\\Administrator", 
            "Email":"", 
            "Notes":"", 
            "IsSiteAdmin":true, 
            "RegionalSettings":null
        }, 
        "Port":80, 
        "PortalName":null, 
        "PortalUrl":null, 
        "Protocol":"http:", 
        "ServerRelativeUrl":"/PWA", 
        "Url":"http://p3uk64p12/PWA"
    }, 
    "Web":
    {
        "AllProperties":
        {
            "vti_usernames":"", 
            "vti_approvallevels":"Approved Rejected Pending\\ Review", 
            "vti_defaultlanguage":"en-us", 
            "vti_extenderversion":"12.0.0.6219", 
            "vti_categories":"Business Competition Expense\\ Report Goals/Objectives Ideas In\\ Process Miscellaneous Planning Schedule Travel VIP Waiting", 
            "vti_associategroups":"3"
        }, 
        "Author":
        {
            "Name":"P3UK64P12\\Administrator", 
            "Email":"", 
            "Notes":"", 
            "IsSiteAdmin":true, 
            "RegionalSettings":null
        }, 
        "Created":"7/24/2008 9:08:56 AM", 
        "CurrencyLocaleID":1033, 
        "CurrentUser":
        {
            "Name":"System Account", 
            "Email":"", 
            "Notes":"", 
            "IsSiteAdmin":true, 
            "RegionalSettings":null
        }, 
        "Features":
        {
        }, 
        "ID":"a5c5a494-5260-41da-9c60-fcf76d7e92e8", 
        "IsRootWeb":true, 
        "Language":1033, 
        "LastItemModifiedDate":"12/1/2008 3:38:52 PM", 
        "Locale":"English (United States)", 
        "Name":"", 
        "Navigation":
        {
            "UseShared":false
        }, 
        "PublicFolderRootUrl":null, 
        "QuickLaunchEnabled":true, 
        "RegionalSettings":
        {
            "LocaleId":1033, 
            "CalendarType":1, 
            "Time24":false, 
            "AdjustHijriDays":0, 
            "Collation":25, 
            "AlternateCalendarType":0, 
            "ShowWeeks":false, 
            "FirstWeekOfYear":0, 
            "WorkDays":62, 
            "WorkDayStartHour":480, 
            "WorkDayEndHour":1020, 
            "FirstDayOfWeek":0
        }, 
        "ServerRelativeUrl":"/PWA", 
        "Title":"Project Web Access", 
        "Url":"http://p3uk64p12/PWA", 
        "UserIsSiteAdmin":true, 
        "UserIsWebAdmin":true, 
        "WebTemplate":"PWA", 
        "WebTemplateId":6221
    }
};

The context on a Project Server PWS "New" Risks page:
var p3context = /*
  Created by JsonExSerializer
  Assembly: Pcubed.ShUIE, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e10d7838767586ca
  Type: Pcubed.ShUIE.JsonContext
*/
{
    "CurrentList":
    {
        "AllowRssFeeds":true, 
        "Author":
        {
            "Name":"System Account", 
            "Email":"", 
            "Notes":"", 
            "IsSiteAdmin":false, 
            "RegionalSettings":null
        }, 
        "BaseTemplate":1101, 
        "BaseType":0, 
        "CanReceiveEmail":false, 
        "ContentTypes":
        {
        }, 
        "ContentTypesEnabled":false, 
        "Created":"12/1/2008 3:38:38 PM", 
        "DefaultContentApprovalWorkflowId":"00000000-0000-0000-0000-000000000000", 
        "DefaultItemOpen":0, 
        "DefaultViewID":"a68ef66f-6ab5-40c0-b3ca-ab966fa3f8a4", 
        "DefaultViewImageUrl":"/_layouts/images/pwsrisks.png", 
        "DefaultViewTitle":"All Items", 
        "DefaultViewUrl":"/PWA/Test Project 1/Lists/Risks/AllItems.aspx", 
        "Description":"Use the Risks list to manage a set of risks related to this project. You can assign, prioritize, and follow the progress of risks from start to finish.", 
        "Direction":"none", 
        "EmailAlias":null, 
        "EnableVersioning":false, 
        "Folders":
        {
        }, 
        "ForceCheckout":false, 
        "ID":"f54efb56-a41e-466f-b06b-cdec039cf4b4", 
        "ImageUrl":"/_layouts/images/itpwsris.gif", 
        "ItemCount":0, 
        "LastItemModifiedDate":"12/1/2008 4:41:20 PM", 
        "MobileDefaultViewUrl":"", 
        "OnQuickLaunch":true, 
        "Ordered":false, 
        "TemplateFeatureId":"448e1394-5e76-44b4-9e1c-169b7a389a1b", 
        "Title":"Risks", 
        "Version":9
    }, 
    "Fields":
    [
        {
            "AuthoringInfo":null, 
            "CanToggleHidden":true, 
            "DefaultValue":"0", 
            "Description":"The cost impact should the risk actually happen", 
            "Direction":"none", 
            "DisplaySize":null, 
            "FieldReferences":null, 
            "Filterable":true, 
            "FromBaseType":false, 
            "Id":"fc23c839-b668-4aec-aac7-6453014cc6b7", 
            "InternalName":"Cost", 
            "ReadOnlyField":false, 
            "Reorderable":true, 
            "Required":false, 
            "Scope":"/PWA/Test Project 1", 
            "StaticName":"Cost", 
            "Title":"Cost", 
            "TypeAsString":"Currency"
        }
    ], 
    "FormMode":"Invalid", 
    "IsDesignTime":false, 
    "ItemId":0, 
    "Lists":
    [
        {
            "BaseTemplate":1100, 
            "BaseType":0, 
            "DefaultViewID":"faa783bc-a0b1-4354-953d-d5b2ae272aee", 
            "DefaultViewImageUrl":"/_layouts/images/pwsissues.png", 
            "DefaultViewTitle":"All Items", 
            "DefaultViewUrl":"/PWA/Test Project 1/Lists/Issues/AllItems.aspx", 
            "Description":"Use the Issues list to manage a set of issues related to this project. You can assign, prioritize, and follow the progress of issues from start to finish.", 
            "ID":"0e976dbc-1eae-4b31-9dbf-99634b5f26ed", 
            "ImageUrl":"/_layouts/images/itissue.gif", 
            "ItemCount":0, 
            "OnQuickLaunch":true, 
            "Title":"Issues"
        }
    ], 
    "Site":
    {
        "HostName":"p3uk64p12", 
        "ID":"f43bea00-92a4-443b-8630-479d0e2cd548", 
        "LastContentModifiedDate":"12/1/2008 4:41:20 PM", 
        "Owner":
        {
            "Name":"P3UK64P12\\Administrator", 
            "Email":"", 
            "Notes":"", 
            "IsSiteAdmin":true, 
            "RegionalSettings":null
        }, 
        "Port":80, 
        "PortalName":null, 
        "PortalUrl":null, 
        "Protocol":"http:", 
        "ServerRelativeUrl":"/PWA", 
        "Url":"http://p3uk64p12/PWA"
    }, 
    "Web":
    {
        "AllProperties":
        {
            "MSPWAPROJUID":"4b1b86a2-b173-4e94-a104-fbe9848db7f1", 
            "PWAURL":"http://p3uk64p12/pwa", 
            "vti_approvallevels":"Approved Rejected Pending\\ Review", 
            "vti_defaultlanguage":"en-us", 
            "vti_extenderversion":"12.0.0.6219", 
            "vti_categories":"Business Competition Expense\\ Report Goals/Objectives Ideas In\\ Process Miscellaneous Planning Schedule Travel VIP Waiting"
        }, 
        "Author":
        {
            "Name":"System Account", 
            "Email":"", 
            "Notes":"", 
            "IsSiteAdmin":false, 
            "RegionalSettings":null
        }, 
        "Created":"12/1/2008 3:38:33 PM", 
        "CurrencyLocaleID":1033, 
        "CurrentUser":
        {
            "Name":"System Account", 
            "Email":"", 
            "Notes":"", 
            "IsSiteAdmin":true, 
            "RegionalSettings":null
        }, 
        "Features":
        {
        }, 
        "ID":"fbe6e5c4-611c-4269-9e47-2e40eab1c4c0", 
        "IsRootWeb":false, 
        "Language":1033, 
        "LastItemModifiedDate":"12/1/2008 4:41:20 PM", 
        "Locale":"English (United States)", 
        "Name":"Test Project 1", 
        "Navigation":
        {
            "UseShared":false
        }, 
        "PublicFolderRootUrl":null, 
        "QuickLaunchEnabled":true, 
        "RegionalSettings":
        {
            "LocaleId":1033, 
            "CalendarType":1, 
            "Time24":false, 
            "AdjustHijriDays":0, 
            "Collation":25, 
            "AlternateCalendarType":0, 
            "ShowWeeks":false, 
            "FirstWeekOfYear":0, 
            "WorkDays":62, 
            "WorkDayStartHour":480, 
            "WorkDayEndHour":1020, 
            "FirstDayOfWeek":0
        }, 
        "ServerRelativeUrl":"/PWA/Test Project 1", 
        "Title":"Test Project 1", 
        "Url":"http://p3uk64p12/PWA/Test Project 1", 
        "UserIsSiteAdmin":true, 
        "UserIsWebAdmin":true, 
        "WebTemplate":"PWS", 
        "WebTemplateId":6215
    }
};

Last edited Dec 5, 2008 at 1:33 PM by DavidK, version 5

Comments

No comments yet.