Field is empty after saving
Hi all,
I'm a bit confused. The script add the current user name to a text field. When i save, the field is empty.
SP.SOD.executeOrDelayUntilScriptLoaded((function () {
if (fd.field('User').value() == '') {
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 () {
fd.field('User').value(user.get_title());
});
}
}), "SP.js");
//disable field
fd.field('User').readonly(true);
What is wrong?
Best wishes
Tom
I'm a bit confused. The script add the current user name to a text field. When i save, the field is empty.
SP.SOD.executeOrDelayUntilScriptLoaded((function () {
if (fd.field('User').value() == '') {
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 () {
fd.field('User').value(user.get_title());
});
}
}), "SP.js");
//disable field
fd.field('User').readonly(true);
What is wrong?
Best wishes
Tom
Hello Tom,
Most browsers don’t send values of disabled fields to the server during the submission, so they will be lost. So you need to enable the field before the submission in onsubmit handler.
Most browsers don’t send values of disabled fields to the server during the submission, so they will be lost. So you need to enable the field before the submission in onsubmit handler.
Code: Select all
fd.onsubmit(function () {
fd.field('User').readonly(false);
return true;
});
-
- Information
-
Who is online
Users browsing this forum: No registered users and 15 guests