/*****************************************************************************
The JavaScript code from this section will be executed while loading
the current form.
The following predefined variables can be utilized in the code:
fd - instance of the current form
$ - jQuery object
Dialog - object for opening and closing dialogs
spfxContext - current SharePoint context
PnPjs library
https://pnp.github.io/pnpjs/
sp - sp object from PnPjs:
graph - graph object from PnPjs
Site - Site function from PnPjs
Web - Web function from PnPjs
==============================================================================
*/
fd.spRendered(function () {
// This code is executed once the form is rendered
fd.field("Title").value = "WAHOO!";
fd.container('Tabs1').setTab(1);
});
fd.spBeforeSave(function () {
// This code is exeuted before saving the form and
// may return Promise. The saving does not proceed until
// the Promise is resolved. If the Promise is rejected,
// the saving interrupts. This is the appropriate place
// for adding custom validation.
// Prevent saving if Status is set to 'Resolved' but
// Comments field is empty
if (fd.field('Status').value === 'Resolved' &&
!fd.field('Comments').value) {
throw Error('Please leave a comment.');
}
});
fd.spSaved(function (result) {
// This code is executed after saving the form
});
*****************************************************************************/
Neither things under spRendered seem to execute. Does not change the tab, does not set the field value.
BUT setting that same code (the set field value and the set tab) in the button on the form, it does execute. It sets the field value, changes the tab.