Field is empty after saving

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
TWendt
Posts: 109
Joined: Mon Sep 08, 2014

08 Jul 2020

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

User avatar
mnikitina
Posts: 264
Joined: Wed Jun 05, 2019

09 Jul 2020

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.

Code: Select all

fd.onsubmit(function () {
  fd.field('User').readonly(false);
  return true;
});

TWendt
Posts: 109
Joined: Mon Sep 08, 2014

16 Jul 2020

Hi Mnikitina

many thanks for your support. It works fine.

Bets wishes
Tom

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 15 guests