AnsweredAssumed Answered

Model don't save on record action

Question asked by Felippe Junger on Jul 10, 2018
Latest reply on Aug 2, 2018 by Eugene Bychkov

Hello Guys, I'm with this problem:

I have a custom record action on Meetings module. This action get the current device location, after that the start_date and a boolean custom field are modified, I do a save in the current model the detail view look like ok this the fields changes, but if I reload the detailview or enter on editview, change anything and save, the fields changed on record action back to the old values.

 

Could someone help me with this?
Sdk version: 

6.1.2.459-1.4.1-2

 

Checkin action:

customization.registerRecordAction({
    name    : 'check-in',
    types   : ['toolbar'],
    modules : ['Meetings'],
    label   : 'Check-in',
    iconKey : 'sorting.checked',
    handler : handler,
    rank    : 0,
    stateHandlers: {
        // Implement: for example, check if the record has enough information to make a checkout.
        isEnabled(view, model) {
            return !model.get('sng_checkin_realizado_c') && model.get('status') != 'realizada' && model.get('status') != 'Not Held';
        },
    },
});

checkin handler function:

 

function handler(view, model) {

    geolocationHelper.getLocationWithCache(onGetLocation);

    function onGetLocation(position, status) {

        _atualizaInicioVisita(model);
        _criaCheckIn(position, model, status);
    }
}

updating the meeting model:

function _atualizaInicioVisita(model){

    let camposSave = ['sng_checkin_realizado_c'];

    if(!model.get('sng_checkin_realizado_c')){
        camposSave.push('date_start');
        model.set('date_start', moment().format());
    }

    model.set('sng_checkin_realizado_c', true);
    model.save(null, { fields: camposSave });

}

Attachments

Outcomes