Set a value with Javascript in a Form didn't work

Hello guys,

I tried to set a value manually with JavaScript, but I always get an error message. This is my function:

fd.spRendered(function() {
fd.field('Keyword_x0020_1').value('test');

fd.field('TSName').value = "TSName";

});

and I get the following error message:

Uncaught TypeError: fd.spRendered is not a function
at HTMLDocument. (fd_Item_New.aspx?List=5740b9b5-e8de-40a5-83b9-93ec62b71baf&Source=https%3A%2F%2Fintranet.bystronic.com%2FWorkspaces%2FWS_000392%2FLists%2FTSTest%20Specifications%2FTSTest%20Specifications.aspx%3F_c14%3D{(0)%3A0}%26_c16%3D{(0)%3A0}%26_c18%3D{(0)%3A0}%26_c20%3D{(0)%3A0}%26_c22%3D{(0)%3A0}%26SourceUrlKeys%3DStartIndex&RootFolder=&Web=429d108c-7055-45ae-9d88-06e6aa69a14e:967)
at j (plumsail.fd.jquery.js?rev=uWqMkVfr%2B6VHuu0VYpVNCg%3D%3DTAG0:2)
at Object.fireWith [as resolveWith] (plumsail.fd.jquery.js?rev=uWqMkVfr%2B6VHuu0VYpVNCg%3D%3DTAG0:2)
at Function.ready (plumsail.fd.jquery.js?rev=uWqMkVfr%2B6VHuu0VYpVNCg%3D%3DTAG0:2)
at HTMLDocument.J (plumsail.fd.jquery.js?rev=uWqMkVfr%2B6VHuu0VYpVNCg%3D%3DTAG0:2)

Best regards

Matthias

Hello @Matthias0710,

Welcome to Plumsail Community!

What product are you using? Public Forms or SharePoint forms?

Could you please share the screenshot of the form with the console errors.

Also is it a complete code you are using on the form? Could you please share the screenshot of the code in the designer and where you've used it.

Hi,

it's just a testing for the SharePoint forms. The screenshot is in the answer.

Thanks for your help!!

Screenshot-Plumsail|690x258

Best regards

Matthias

Hello @Matthias0710,

Thank you for the screenshot!

You are using Forms Designer for Classic UI, and spRendered() works in Plumsail Forms for Modern UI only.

Using Forms Designer, to disable and populate field on form load, please use this code:

fd.field('TSName').readonly(true);
fd.field('TSName').value('TSName');

Note, that you need to enable field before the submission:

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

Also, I would suggest you to test out Plumsail Forms for Modern UI, as it has more controls, reacher API and is coastally improved. You can request the trial here: