0

I am creating a request form where below fields are needed:

  1. Name:
  2. Location:
  3. Contact:
  4. Manager:

Now requirement is, once name is entered rest 3 fields should be autofilled.

Can I apply below logic?

  • Capture name.
  • From that name, user id will be mapped to UserInformationList (Default list in sharepoint)
  • From that user id rest details can be autofilled from list.

Queries:

  1. How to map user ID from my list to UserInformationList?
  2. How to Capture these details on form in realtime?

No workflow to be used!

  • How are you planning to handle individuals with the same name??? – jpollar Jun 18 '18 at 15:12
  • we maintain a company ID which when entered in people picker gets converted to user name. hence same isnt an issue as company id is unique. Do you have an example solution for it? – Sanjana Chhabira Jun 19 '18 at 15:55
0

You can fetch data from User Information list using JSOM.

An example for your reference:

ExecuteOrDelayUntilScriptLoaded(getUserProfile, "sp.js");
function getUserProfileInformation(){
    var userID = _spPageContextInfo.userId;
    var clientContext = new SP.ClientContext.get_current();
    var web = clientContext.get_web();
    var userInfoList = web.get_siteUserInfoList();
    var camlQuery = new SP.CamlQuery();
    camlQuery.set_viewXml("" + userID + "1");
    this.collListItem = userInfoList.getItems(camlQuery);
    clientContext.load(collListItem);
    clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}

function onQuerySucceeded(sender, args){
    var item = collListItem.itemAt(0);
    var MyuserName = item.get_fieldValues().UserName;
    var MydisplayName = item.get_fieldValues().Title;
    var Myemail = item.get_fieldValues().EMail;
    var html = "";
    if(MyuserName !=null){
        html += "<img src='/_layouts/15/userphoto.aspx?size=S&username=" + MyuserName + "'/>";
    }
    if(displayName != null){
        html += "Name:" + MydisplayName + "";
    }
    if(email != null){
        html += "Email: " + Myemail + "";
    }
    var profileDiv = document.getElementById("CurrentUserProfile");
    profileDiv.innerHTML = html;
}

function onQueryFailed(sender, args) {
    //alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}

More information: How to get User Information List information using JSOM in SharePoint 2013/2016/online

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.