How to use save and close method in record js

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 ?

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
({
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",
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX