I am using save and close method in create.js to validate before save and it's working fine in create.js , how can i use the same code in record.js ?
({
extendsFrom: 'CreateView',
initialize: function (options) {
this._super('initialize', [options]);
},
saveAndClose: function () {
var APIURL = "rest/v10/WPE_Work_Product_Enrollment?erased_fields=true&max_num=1&order_by=date_entered:desc";
var self = this;
this._TestSysItem().then(function thenFunc(result) {
console.log('termination_date_c out of api:',result);
App.api.call("get", APIURL, null, {
success: function (Data) {
if(Data.records.length > 0)
{
var lastwp = Data.records[0].m03_work_product_wpe_work_product_enrollment_1_name;
var lastStatus = Data.records[0].enrollment_status_c;
if((lastwp!="APS001-AH01" && lastStatus =='On Study') || (result!=''))
{
app.alert.show("no_wpa_error",
{
level: "error",
autoClose: true,
messages: "New record can not create with this selection"
});
}
else
{
self.initiateSave(_.bind(function initSave() {
if (self.closestComponent("drawer")) {
app.drawer.close(self.context, self.model);
}
}, self));
}
}
}
});
}.bind(this));
},