pre populating fields
Posted: 21 Apr 2017
Hi
I am trying to pre populate information in a form based on the user that is currently logged in. I am using the below function by clicking JS on the form and changing the field name to my fields internal name but nothing happens, please assist
// Load current user login
SP.SOD.executeOrDelayUntilScriptLoaded((function () {
var ctx = new SP.ClientContext.get_current();
var web = ctx.get_web();
ctx.load(web);
var user = web.get_currentUser();
user.retrieve();
ctx.executeQueryAsync(
function () {
// Set user login
fd.field('Customer').control().value(user.get_loginName());
// Run validation by emulating validation image click
fd.field('Customer').control()._el().find('a:eq(0)').click();
});
}), "SP.js");
I am trying to pre populate information in a form based on the user that is currently logged in. I am using the below function by clicking JS on the form and changing the field name to my fields internal name but nothing happens, please assist
// Load current user login
SP.SOD.executeOrDelayUntilScriptLoaded((function () {
var ctx = new SP.ClientContext.get_current();
var web = ctx.get_web();
ctx.load(web);
var user = web.get_currentUser();
user.retrieve();
ctx.executeQueryAsync(
function () {
// Set user login
fd.field('Customer').control().value(user.get_loginName());
// Run validation by emulating validation image click
fd.field('Customer').control()._el().find('a:eq(0)').click();
});
}), "SP.js");