I created field in Call entity named time_call. I'm trying the set the date completed and time_call when the status has been changed to "Held". Not sure how to do it on the server side, so I tried to do it on the client side (client/modules/crm/src/views/call/detail.js) in the setup function. The fields are changing when the field is held, but it is not shown when I change the status or even after I update/save it. I would have to update/save, get out of the Call item, then go back in it just to see the fields changed. My code is below. This issue to resolved is on a time clock. I would very appreciate a quick response. Also is there a isfieldchanged on the client side, or do I just use model.hasChange([attribute])?
Code:
if(this.getAcl().checkModel(this.model,'edit')){ // if(['Held'].indexOf(this.model.get('status')) != -1){ if(this.model.get('status') == "Held"){ // var diff = (moment(this.model.get('dateCompleted')).unix() - moment(this.model.get('dateStart')).unix()) / 3600; var dateEnd = moment(this.model.get('dateEnd')).unix(); var dateStart = moment(this.model.get('dateStart')).unix(); var diff = Math.abs(dateEnd) - Math.abs(dateStart); var time_call = Math.ceil((Math.floor(diff) / 3600) * 100) / 100; this.model.save({ 'dateCompleted': this.getDateTime().getNow(), 'time_call': time_call }); } else{ this.model.save({ 'dateCompleted':null, 'time_call':null }); } }
Comment