- tonystarksAsked 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.
- JotForm SupportAdrianAnswered 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. http://prepopulate.jotform.io/
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;
- tonystarksAnswered 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.
- JotForm SupportEltonCrisAnswered on March 21, 2018 at 05:26 AM
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.
var ifrm = document.createElement("iframe");
ifrm.style.width = "100%";
ifrm.style.height = "480px";
ifrm.style.border = "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.