Talep BeforeSave Script

Talep BeforeSave Script

if(!this.recordService.lastData){
  this.recordService.formGroup.controls.TYPEID.setValue(100);
  this.recordService.formGroup.controls.TYPEID_NAME.setValue('New Requisition');
  this.recordService.formGroup.controls.TDATE.setValue(moment());
  this.recordService.formGroup.controls.TTIME.setValue(moment().format('YYYY-MM-DD HH:mm:ss'));
  this.recordService.formGroup.controls.CREATORID_USERCODE.setValue('');
}
 
return new Promise((resolve, reject) => {
   console.log('this', this);
   const stocksGrid = this.recordService.grids['stock-demand-fiches-details'];
   let rowCount = 0;
   let valid = true;
   stocksGrid.api.forEachNode(rowNode => {
     const data = rowNode.data;
     if (!data.STOCKID_NAME || !data.STOCKID || !data.QUANTITY) {
       valid = false;
     }
     rowCount++;
   });
   if (rowCount === 0) {
     angus.api.angusDialog.error(
       angus.languageService.dynamicTranslator.translate('At least one stock needs to be added.')
     );
     return resolve(false);
   }
   if (!valid) {
     angus.api.angusDialog.error(
       angus.languageService.dynamicTranslator.translate('Please set stock names and quantities first.')
     );
     return resolve(false);
   }
   resolve(true);
 });

Last updated