1

We are using SP2013 on-premise (standard edition). I am working on a Master page and user require the staff ID (one of user profile property) to be displayed at the right top corner. (at the element welcomeMenuBox).

May I know:

  1. How to get the value?
  2. How to modify the Master page to show the value?

Thank you.

2 Answers 2

2

Add these to your master page where you would like to display the user ID. PropertyName should be the name of the user property.

Also includes example how to get the StaffId parameter into JavaScript variable and use jQuery to inject ot somewhere on the page.

<%@ Register TagPrefix="SPSWC" Namespace="Microsoft.SharePoint.Portal.WebControls" Assembly="Microsoft.SharePoint.Portal, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>    
<SPSWC:ProfilePropertyLoader runat="server" />

<script type="text/javascript">
    var staffId = '<SPSWC:ProfilePropertyValue PropertyName="StaffID" ApplyFormatting="False" TitleMode="True" runat="server" />';
    $("#findribbonitemhere").append(staffId);
</script>
5
  • Thanks it work. Now I only need to find a way to insert this lines within Ribbon...
    – Mark L
    Commented May 13, 2015 at 8:36
  • Added more details to answer
    – Jussi Palo
    Commented May 13, 2015 at 8:57
  • Sorry for come back this closed question. I am able to add the code into my Master pge directly but I don't know how to add it to the HTML master page. I used <!--SPM:<SPSWC:ProfilePropertyValue PropertyName="username" ApplyFormatting="False" TitleMode="True" runat="server" />--> and it keep saying Unknown server tag 'SPSWC:ProfilePropertyValue'.
    – Mark L
    Commented Jun 2, 2015 at 3:07
  • You need to include this at the top: <!--SPM:<%@ Register TagPrefix="SPSWC" Namespace="Microsoft.SharePoint.Portal.WebControls" Assembly="Microsoft.SharePoint.Portal, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>-->
    – Jussi Palo
    Commented Jun 2, 2015 at 6:54
  • Sorry for posting in someone else thread. I am trying to achieve the same in 2016 i added the Register entry with version changed to 16.0.0.0 in html. But i am getting unknown server tag. when i open the .master i dont see the register entry i added. Please help
    – user9167
    Commented Dec 9, 2016 at 16:52
0

Its easy.

https://msdn.microsoft.com/en-us/library/office/jj163800.aspx

User profiles and user profile properties provide information about SharePoint users. SharePoint Server 2013 provides the following APIs that you can use to programmatically work with user profiles:

Client object models for managed code

.NET client object model

Silverlight client object model

Mobile client object model

JavaScript object model

Representational State Transfer (REST) service

Server object model

The above MSDN link has got info of how to use each.

I think you should use JavaScript object model-> https://msdn.microsoft.com/EN-US/library/office/jj920104.aspx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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