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:
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.load(personProperties);
clientContext.executeQueryAsync(gotAccount, requestFailed);
}
function gotAccount(sender, args) {
alert('Running...');
document.getElementById("MSOPageViewerWebPart_WebPartWPQ2").src="https://server.com/InternalProfileInformation.php?userName="+personProperties.get_accountName();
}
function requestFailed(sender, args) {
alert('Cannot get user account information: <br>' + args.get_message());
}
</script>
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.