How do I get the logged in SharePoint user and populate it to the form?

  • Profile Image
    Asked on March 20, 2018 at 09:38 AM

    I have a form embedded in a SharePoint. We want to get the email of the user logged in it and have it prepopulated or maybe include it in the output.

  • Profile Image
    Answered on March 20, 2018 at 11:35 AM

    If I understand you correctly, you want to get the email address of the logged in user in SharePoint and prepopulate the form with it.

    Prepopulating the form is quite easy. You can generate the prepopulated URL using our PrePopulate Application.

    Complete Guide: Prepopulating Fields to Your JotForm via URL Parameters

    To get the email of the currently logged in user, try the following C# code.

    SPWeb web = SPContext.Current.Web;

  • Profile Image
    Answered on March 20, 2018 at 11:27 PM

    Yes you are correct. That's what i want to accomplish. But i'm not sure where to put the C# codes in the form.

  • Profile Image
    Answered on March 21, 2018 at 05:26 AM

    If it's the username from Sharepoint that you want to get, you can try the script provided on this page

    Then you can prepopulate it in your form through URL parameter.

    To do that, you need to add a username field in your form and then make it hidden or whichever you prefer.

    Then in your embed code, you will have to construct it like the following to catch the username value.


    <div id="jot"></div>

    <script type="text/javascript">

        var username="John";

            var ifrm = document.createElement("iframe");

            ifrm.setAttribute("src", ""+username);

   = "100%";

   = "480px";

   = "0";



    You need to pass the value into the variable username so it would be populated to the form.

    Also, replace the form URL above with your form URL. You also need to adjust the width and height of the frame.