3

I am using SharePoint 2013 and I have created a survey form which contains User ID related question. I would like to populate current User info in that field.

  1. I tried by using [Me] as calculate the value in single line text item. It is working partially as I see some junk characters prefixed with Domain Name/Username. So I am unable to use it.
  2. I try to Add Current User Filter and text filter in web parts, but it value displayed in text Filter, I am unable to save it in the survey response.

Kindly suggest how I can populate username in Survey text box?

Appreciate detailed explanation.

  • 1
    Would you feel comfortable using JavaScript? If it were me, I would use JSLink and the _spPageContextInfo object to populate it. Otherwise, have you tried a person/group field instead of plain text? Why do you need plain text? – Kevin Stone May 31 '17 at 18:59
  • Hi @Sive, welcome to SharePoint StackExchange :) , Could you please take a quick tour at sharepoint.stackexchange.com/tour to get informed badge :) Thank you for your contribution :) – Mohamed El-Qassas MVP May 31 '17 at 19:16
2

The current user information available on SharePoint page which you can get it from the JavaScript and assign to your textboxes.

I am using jQuery in the following syntax

<input type="text" id="txtUserId" >

<script type="text/javascript">
$(document).ready(function() {
   var userId = _spPageContextInfo.userId;
   var userEmail = _spPageContextInfo.userEmail;
   var userDisplayName = _spPageContextInfo.userDisplayName;
   var userLogin = _spPageContextInfo.userLoginName;

   //If you want to assign user id to textbox
   $("#txtUserId").val(userId);
});
</script>

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.