Rajesh
Rajesh 👨🏻‍💻developer, architect, consultant focussed on modernization, cognitive services, and conversational ai.

Access _spPageContextInfo details in SharePoint Framework

Access _spPageContextInfo details in SharePoint Framework

If you are into SharePoint development, then you should be familiar with your best friend _spPageContextInfo which gives you more valuable context based information. You can also access the same now from SharePoint Framework too.

Shows how to get current user display name.

1
2
3
4
5
6
// This is how you can access the page context info
this.context.pageContext.legacyPageContext;
// Retreive current user display name
this.context.pageContext.legacyPageContext['userDisplayName']);
// Even site classification
this.context.pageContext.legacyPageContext['siteClassification']);

Below is the complete list of object’s properties which sample values,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
CorrelationId : "b215479e-f056-5000-11a1-ec000000000010" 
DesignPackageId : "00000000-0000-0000-0000-000000000000" 
PreviewFeaturesEnabled: true 
PublishingFeatureOn : false 
ReycleBinItemCount : -1 
aadInstanceUrl : "https://login.windows.net" 
aadTenantId : "96d8e75d--14a031e2320f" 
aadUserId : "e7d71f70-13e9-0000-0000-86d1269cd536" 
alertsEnabled : true 
allowSilverlightPrompt : "True" 
blockDownloadsExperienceEnabled : false 
canUserCreateMicrosoftForm : true 
canUserCreateVisioDrawing : true 
cdnPrefix : "static.sharepointonline.com/bld" 
crossDomainPhotosEnabled : true 
currentCultureLCID : 1033 
currentCultureName : "en-US" 
currentLanguage : 1033 
currentUICultureName : "en-US" 
departmentId : null 
disableAppViews : false 
disableFlows : false 
env : "prod" 
farmLabel : "US_9_Content" 
fid : 16190 
formDigestTimeoutSeconds : 1800 
groupColor : "#188387" 
groupHasHomepage : true 
groupHasQuickLaunchConversationsLink : false 
groupId : "c771d35a-fee4-4447-9c0a-6c0b199d00fc" 
groupType : "Private" 
guestsEnabled : false 
hasManageWebPermissions : true 
hasPendingWebTemplateExtension : false 
hideSyncButtonOnODB : false 
hubSiteId : null 
idleSessionSignOutEnabled : false 
isAnonymousGuestUser : false 
isAppWeb : false 
isEmailAuthenticationGuestUser : false 
isExternalGuestUser : false 
isHubSite : false 
isMultiGeoTenant : false 
isNoScriptEnabled : true 
isSPO : true 
isSiteAdmin : true 
isTenantDevSite : false 
isWebWelcomePage : false 
layoutsUrl: "_layouts/15" 
listBaseTemplate : 100 
listId : "{7069a902-4347-000-8a03-00fceecfdc70}" 
listPermsMask : {High: 2147483647, Low: 4294705151} 
listTitle : "Property Locations" 
listUrl : "/sites/DemoModernTeamSite/Lists/Property Locations" 
maximumFileSize : 15360 
msGraphEndpointUrl : "graph.microsoft.com" 
navigationInfo : {quickLaunch: Array(14), topNav: Array(2)} 
nid : 107 
openInClient : false 
pageItemId : -1 
pageListId : "{7069a902-0000-4000-8a03-21fceecfdc70}" 
pagePermsMask : null 
pagePersonalizationScope : 1 
preferUserTimeZone : false 
readOnlyState : null 
serverRedirectedUrl : null 
serverRequestPath : "/sites/DemoModernTeamSite/Lists/Property Locations/AllItems.aspx" 
serverTime : "2018-02-04T04:58:48.0656761Z" 
showNGSCDialogForSyncOnODB : false 
howNGSCDialogForSyncOnTS : true 
siteAbsoluteUrl : "https://constoso.sharepoint.com/sites/DemoModernTeamSite" 
siteClassification : "" 
siteClientTag : "0$$16.0.7324.1203" 
siteColor : "#188387" 
siteId : "{1c2e6438-80d2-40cc-9bc5-5aa657c00000}" 
sitePagesEnabled : true 
siteServerRelativeUrl : "/sites/DemoModernTeamSite" 
siteSubscriptionId : "0f6d0000-f22c-47d7-a17f-cd78e6b74a54" 
supportPercentStorePath : true 
supportPoundStorePath : true 
systemUserKey : "i:0h.f|membership|[email protected]" 
tenantAppVersion : "3704586950" 
themeCacheToken : "/sites/DemoModernTeamSite:/sites/DemoModernTeamSite/_catalogs/theme/Themed/6FE0689A:9:16.0.7324.1203" 
themedCssFolderUrl : "/sites/DemoModernTeamSite/_catalogs/theme/Themed/6FE0689A" 
themedImageFileNames : {spcommon.png: "spcommon-B35BB0A9.themedpng?ctag=9", 
  ellipsis.11x11x32.png: "ellipsis.11x11x32-2F01F47D.themedpng?ctag=9", 
    O365BrandSuite.95x30x32.png: "O365BrandSuite.95x30x32-C212E2FD.themedpng?ctag=9", 
      socialcommon.png: "socialcommon-6F3394A9.themedpng?ctag=9", 
        spnav.png: "spnav-230C537D.themedpng?ctag=9", } 
userDisplayName : "Rajesh Sitaraman" 
userEmail : "[email protected]" 
userFirstDayOfWeek : null 
userId : 3 
userLoginName : "[email protected]" 
userTime24 : false 
userTimeZoneData : null 
viewId : "{7edde8c2-5458-42b4-0000-883094b3837e}" 
viewOnlyExperienceEnabled : false 
webAbsoluteUrl : "https://contoso.sharepoint.com/sites/DemoModernTeamSite" 
webDescription : "Demo Modern Team Site" 
webFirstDayOfWeek : 0 
webId : "{8985f800-0000-42f2-899a-abb9f24251e3}" 
webLanguage : 1033 
webLogoUrl : "/sites/DemoModernTeamSite/_api/GroupService/GetGroupImage? 
id='8c1914df-0000-4088-a812-96183d42ae27'&hash=636533140690897999" 
webPermMasks : {High: 2147483647, Low: 4294705151} 
webServerRelativeUrl : "/sites/DemoModernTeamSite" 
webTemplate : "64" 
webTemplateConfiguration : "GROUP#0" 
webTime24 : false 
webTimeZoneData : {Description: "(UTC-08:00) Pacific Time (US and Canada)", 
  Bias: 480, Id: 13, DaylightBias: -60, DaylightDate: {}, } 
webTitle : "Demo Modern TeamSite" 
webUIVersion : 15

comments powered by Disqus