SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We are using js code to access user profile properties on an application page.

Error: The property or field 'UserProfileProperties' has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.

Code: ( ContentPlaceHolderID="PlaceHolderAdditionalPageHead" )

      <SharePoint:ScriptLink ID="ScriptLink1" name="SP.js" runat="server"
    ondemand="false" localizable="false" loadafterui="true" />
<SharePoint:ScriptLink ID="ScriptLink2" name="SP.UserProfiles.js" runat="server"
    ondemand="false" localizable="false" loadafterui="true" />

<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<script type="text/javascript">
    var personProperties;

    // Ensure that the SP.UserProfiles.js file is loaded before the custom code runs.
    SP.SOD.executeOrDelayUntilScriptLoaded(getUserProperties, 'SP.UserProfiles.js');

    function getUserProperties() {

        // Get the current client context and PeopleManager instance.
        var clientContext = new SP.ClientContext.get_current();
        var peopleManager = new SP.UserProfiles.PeopleManager(clientContext);

        // Get user properties for the target user.
        // To get the PersonProperties object for the current user, use the
        // getMyProperties method.
        personProperties = peopleManager.getMyProperties();

        // Load the PersonProperties object and send the request.
        clientContext.executeQueryAsync(onRequestSuccess, onRequestFail);

    // This function runs if the executeQueryAsync call succeeds.
    function onRequestSuccess() {

        if (personProperties.get_userProfileProperties()['MyCustomProperty'] == 'True') {




    // This function runs if the executeQueryAsync call fails.
    function onRequestFail(sender, args) {




What could be possible cause, I have used executeOrDelayUntilScriptLoaded..

share|improve this question

I think this row

if (personProperties.get_userProfileProperties()['MyCustomProperty'] == 'True')

should be

if (personProperties.get_userProfileProperties().MyCustomProperty == 'True')

(idea from

Also, you should probably use

SP.SOD.executeFunc('SP.js', 'SP.ClientContext', function() {
   // Make sure PeopleManager is available 
   SP.SOD.executeFunc('userprofile', 'SP.UserProfiles.PeopleManager', function() {

from Are the SP.js and SP.UserProfiles.js preloaded in SharePoint? instead of using executeOrDelay since these scripts are on-demand scripts.

Edit Seems userProfileProperties is not loaded, how about:

    // getMyProperties method.
    personProperties = peopleManager.getMyProperties();
   upProperties =  personProperties.get_userProfileProperties();
    // Load the PersonProperties object and send the request.
    clientContext.executeQueryAsync(onRequestSuccess, onRequestFail);

And then work with upProperties in the onRequestSuccess method

share|improve this answer
I vl try this tomorrow. Thanks – variable Mar 24 '14 at 15:50
chagned. still the same issue. – variable Mar 25 '14 at 6:36
See update above – Robert Lindgren Mar 25 '14 at 7:07
Is it that the js is not loaded or property is not loaded? I even tried to use executeordelay for sp.js as well as for sp.userprofiles.. – variable Mar 25 '14 at 7:14
Also, do I need to call the script reference tags? SharePoint:ScriptLink for sp.js and sp.userprofiles.js? – variable Mar 25 '14 at 7:17

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.