What is the best way to catch ALL edits on Approved record?

I have a need to warn the user that they are editing an "Approved" custom record, or one of its related custom records, and allow them to proceed if they so choose, get out without changing anything if they don't.

How do I catch any and all attempts to edit? i.e. full edit button, edit from list or subpanel, inline edit? Did I miss any?

Hopefully I can catch them all in one place but if the only option is by view controller, what are all the controllers I need to worry about?

thanks

FrancescaS

  • Madam once you are done with this plz do post your answer and also reference link which halped you to sort out.

  • Best suggestion so far, by Angel Maganathis.model.hasChanged()

    Still looking for a way to warn before they make changes.

  • I have separate solutions for subpanel: Quick tip: request confirmation for subpanel inline edit based on parent value 

    And for record view where I check the Approval status in the handleEdit:

      handleEdit: function(e, cell){
        this._super('handleEdit',[e, cell]);
        this.checkApprovalStatus();
      },
      checkApprovalStatus: function(){
        var self = this,
            isSysAdmin = (app.user.get('type') == 'admin'),
           approval_status = self.model.get('contract_approval_status_c');
        if(approval_status == 'Approved' && !isSysAdmin){
          app.alert.show('editing_approved', {
            level: 'confirmation',
            messages: 'Contract already Approved, Confirm to Save Changes and reset Approval Status',
            autoClose: false,
            onConfirm: function(evt){
               self.model.set('contract_approval_status_c', 'Reset');
               //user does not have permissiont to set these so this is just a visual, the actual reset happens in the logic hook
               //ToDo: find a better way
               self.model.set('manager_approval_c', 'NA');
               self.model.set('legal_approval_c', 'NA');
               self.model.set('finance_approval_c', 'NA');
               //self.model.save();
            },
            onCancel: function(){
               self.handleCancel();
            }
          });
        }
      },

    I still have a problem with ACL not resetting the values (the user's role only has read permissions) so I have to play tricks with the logic hook and do a direct database update - which I don't like.

    I use the contract_approval_status_c = 'Reset' to determine when to change the *_approval_c values in the hook

    See: The specified item was not found. 

    HTH

    FrancescaS