I am trying to auto populate user Email, Name, Title on a SharePoint form.

I can see the values when I inspect the page (F12) but they don't appear on the form onLoad.

I can obtain the input fields id via the developer tool, not 100% sure I am using the correct ID.

Here is the code I am using:

$(function () {

function getUserProfileInfo() {

var fullUrl = "https://sites/sites/dome/_api/social.feed/my";

    url: fullUrl,
    type: "GET",
    headers: {
        "accept": "application/json;odata=verbose",
        "content-type": "application/json;odata=verbose",
    success: onUserInfoQuerySucceeded,
    error: onQueryFailed

function onUserInfoQuerySucceeded(data) {
  var userInfoItemE = data.d.Me.EmailAddress;
  var userInfoItemN = data.d.Me.Name;
  var userInfoItemT = data.d.Me.Title;    

  document.getElementById('Email_a6570af6-8b72-4ab0-814d-93f50f26e185_$TextField').innerHTML = userInfoItemE;
  document.getElementById('Name_b6023c0f-43be-45b4-b946-22ac2933bb77_$TextField').innerHTML = userInfoItemN;
  document.getElementById('Title_fa564e0f-0c70-4ab9-b863-0177e6ddd247_$TextField').innerHTML = userInfoItemT;
function onQueryFailed(sender, args) {

Instead of

document.getElementById('Email_a6570af6-8b72-4ab0-814d-93f50f26e185_$TextField').innerHTML = userInfoItemE;


document.getElementById('Email_a6570af6-8b72-4ab0-814d-93f50f26e185_$TextField').value= userInfoItemE;


innerHTML is supposed to manage the child HTML elements. In your case, it procudes invalid HTML. < input > is not supposed to have child elements.

Instead, you want to update value attribute of the input

| improve this answer | |

Your Answer

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

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