There may also be other views you need to take care of, mobile views, inline edit in subpanels etc which may become workarounds to editing.
But let's start with record view, based on Mike Solomon's work (the link I gave you above) to prevent editing you need to work on preventing inline editing and disabling the Edit button in record view:
custom/modules/Cases/clients/base/view/record/record.js
You don’t need an API to check if the Case is closed. You can retrieve field values from within your javascript, inside record.js as long as the page has been rendered.
this.model.get(‘status')
will return the contents of the ‘status’ field for that record.
So to disable inline editing you will create
custom/modules/Cases/clients/base/view/record/record.js
on render, you will disable the inline editing if the status is Completed (the custom checkReadonly function), and when the user clicks "Edit" you will pop up a message that "Edit is not allowed for completed Cases" (in the editClicked function).
(NOTE this code is NOT tested, so there may be errors, always check your console log :) ).({Hope this helps,
extendsFrom: 'RecordView',
initialize: function(options){
this._super('initialize', [options]);
this.on('render',this.checkReadonly,this);
},
checkReadonly: function(){
var status = this.model.get(‘status');
if (status == ‘Completed'){
//do not allow inline edit on any fields
this.editableFields = [];
}
},
editClicked: function(){
//this overrides an existing event handler when "Edit" is clicked
//see original at <sugar_root>/jssource/src_files/clients/base/views/record/record.js
var status = this.model.get(‘status'); //get the status for this record
if (status == ‘Completed'){
//stop the edit button from being used
var msg = 'Edit not allowed for Completed Cases';
app.alert.show(‘case-completed', {
level: 'warning',
messages: msg,
autoClose: true
});
return; //goes back to the view without changing to Edit layout
}else{
//allow the edit
this.setButtonStates(this.STATE.EDIT);
this.toggleEdit(true);
}
},
})
Please can you give me any advise?....i'm a beginner on Sugar Ciao