I need to load a URL in SP2013 in the Page Viewer Web Part (or similar functionality). The basic idea is that it would load http://SERVER.COM/InternalProfileInformation?User=[CurrentlyLoggedInUser].

I found a posting that looks similar here:

Sharepoint Foundation 2013 - getting currently logged on user and passing it in url string/page viewer

I also found a couple other snippets, but I seem to be too dumb to actually implement it. I attempted this using (http://social.msdn.microsoft.com/Forums/sharepoint/en-US/7eb40ea6-23e3-45ca-8a38-69f768dfe4cc/pass-current-users-account-name-into-a-webpart?forum=sharepointdevelopment) as a starting point.

Can anyone give me some help in identifying what exactly I need to do?

I assume I need to add that script to the script editor webpart (probably with some modifications) and then add a page viewer webpart, but I don't know how to get the URL generated in the script into the page viewer settings.

If there is a better way to do this, I am open to it. I've tried created a custom web part, but failed at that, too. At this point, I have many hours into what seemed like it should be a pretty quick process to begin with.

Thanks for any direction!

I think I'm getting closer. I added a two webparts. First is the script editor with the following code:

<script type="text/javascript" src="/_layouts/15/SP.js"></script>
<script type="text/javascript" src="/_layouts/15/SP.UserProfiles.js"></script>

<script type="text/javascript">

  var personProperties;

  SP.SOD.executeOrDelayUntilScriptLoaded(getCurrentUser, 'SP.UserProfiles.js');

  function getCurrentUser() {
    var clientContext = new SP.ClientContext.get_current();
    personProperties = new SP.UserProfiles.PeopleManager(clientContext).getMyProperties();
    clientContext.executeQueryAsync(gotAccount, requestFailed);

  function gotAccount(sender, args) {

  function requestFailed(sender, args) {
    alert('Cannot get user account information: <br>' + args.get_message());


The second is the page viewer. I have it pointing to loading.php so I can easily see if it is getting changed.

In the published view of the page, the contents of loading.php are displayed.
In the edit view of the page, it gets updated with InternalProfileInformation.php's contents.

Any thoughts are appreciated.

  • Made a example of this some days ago as well, you might find it interesting: sharepoint.stackexchange.com/a/97278/627 – eirikb Apr 28 '14 at 19:40
  • Thanks for pointing me in the right direction. I just added some more details above, but now it looks like the javascript is only neing loaded in the edit view. I've tried changing minimal download strategy, but it hasn't made an impact. I've also tried changing calls to SP.runtime.js and how SP.js are called without success. – mswanson Apr 29 '14 at 17:31
  • As a side note, I realized the snippet I included don't mirror your code, but it has a similar idea. I originally had your code, but it also wasn't working reliably. I believe the issue to be the same. – mswanson Apr 29 '14 at 17:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.