Christopher Dembek
03/05/2021, 6:12 PMCustomFormView.prototype.saveForm = function (e) {
e.preventDefault();
var promise = CustomFormView.prototype.saveForm.call(this, e);
if (promise) {
promise
.fail((jqXhr) => {
// Do something with the error code.
jqXhr.preventDefault = true;
const errorCode =
jqXhr &&
jqXhr.responseJSON &&
jqXhr.responseJSON.errorCode && jqXhr.responseJSON.errorCode;
})
.done(() => {
console.log('done');
// Do something when the formModel is saved successfully.
})
.always(() => {
console.log('always');
// Do something always.
});
}
return promise;
}
Error
shopping_1.js?t=1612980274111:4782 Uncaught TypeError: this.formModel.validate is not a function
at a.getFormFieldValue (shopping_1.js?t=1612980274111:4782)
at a.s.onFormFieldChange (shopping.js?t=1612980274111:1)
at HTMLDivElement.dispatch (shopping.js?t=1612980274111:1)
at HTMLDivElement.f.handle (shopping.js?t=1612980274111:1)
at Object.trigger (shopping.js?t=1612980274111:1)
at Object.simulate (shopping.js?t=1612980274111:1)
at HTMLDocument.r (shopping.js?t=1612980274111:1)
Steve Goldberg
03/05/2021, 6:25 PMvalidate()
, or you haven't included a getFormValues
functionSteve Goldberg
03/05/2021, 6:26 PMChristopher Dembek
03/05/2021, 6:27 PMChristopher Dembek
03/05/2021, 6:28 PMChristopher Dembek
03/05/2021, 6:29 PMSteve Goldberg
03/05/2021, 6:29 PMSteve Goldberg
03/05/2021, 6:29 PMChristopher Dembek
03/05/2021, 6:30 PMthis.formModel.on('sync', function () {
Backbone.history.navigate('preferences', {trigger: true});
});
Steve Goldberg
03/05/2021, 6:30 PMChristopher Dembek
03/05/2021, 6:31 PMCustomFormView.prototype.saveForm = function (e) {
e.preventDefault();
var promise = CustomFormView.prototype.saveForm.call(this, e);
if (promise) {
promise
.fail((jqXhr) => {
// Do something with the error code.
jqXhr.preventDefault = true;
const errorCode =
jqXhr &&
jqXhr.responseJSON &&
jqXhr.responseJSON.errorCode && jqXhr.responseJSON.errorCode;
})
.done(() => {
console.log('done');
// Do something when the formModel is saved successfully.
})
.always(() => {
console.log('always');
// Do something always.
});
}
return promise;
}
Steve Goldberg
03/05/2021, 6:32 PMChristopher Dembek
03/05/2021, 6:32 PMChristopher Dembek
03/05/2021, 6:33 PMvar promise = SCFormView.prototype.saveForm.call(this, e);
Steve Goldberg
03/05/2021, 6:33 PMSteve Goldberg
03/05/2021, 6:34 PMSteve Goldberg
03/05/2021, 6:34 PMCustomFormView.prototype.saveForm = function (e) {
e.preventDefault();
var promise = CustomFormView.prototype.saveForm.call(this, e);
Steve Goldberg
03/05/2021, 6:34 PMChristopher Dembek
03/05/2021, 6:34 PMChristopher Dembek
03/05/2021, 7:19 PMfunction ExampleUserPreferencesFormView (options) {
SCFormView.call(this, options.model);
this.formModel.on('sync', function () {
Backbone.history.navigate('preferences', {trigger: true});
});
this.template = example_userpreferences_form_tpl;
}
Christopher Dembek
03/05/2021, 9:52 PMfunction ExampleUserPreferencesModel () {
SCModel.call(this);
this.urlRoot = function urlRoot () {
return Utils.getAbsoluteUrl(
getExtensionAssetsPath(
"Modules/UserPreferences/SuiteScript2/Example.UserPreferences.Service.ss"
), true
)
}
}
Steve Goldberg
03/08/2021, 11:14 AMDoes this trigger a ss2 path?Yes