I want to make the entire opportunity read-only after the opportunity has been marked closed-won. What is the best way to do this?
Thank you,
Jake
I want to make the entire opportunity read-only after the opportunity has been marked closed-won. What is the best way to do this?
Thank you,
Jake
Hi Jake Vernon
Can you check this code and let me know:
In custom/modules/Opportunities/clients/base/views/record/record.js
Under Initialize function add following code:
this.on('render', this.hideAllfields, this);
this.events['change input[name=sales_stage]'] = 'hideAllfields';
Now outside of Initialize function add this code:
hideAllfields: function(){
var ssValue = this.model.get('sales_stage');
if(ssValue == 'Closed Won'){
_.each(this.fields, function(field) {
$('input[name='+field.def.name+']').prop("readonly",true);
$('[data-fieldname="'+field.def.name+'"] input[data-type=date]').prop("readonly",true);
if (_.isEqual(field.def.name, 'sales_stage')) {
$('input[name='+field.def.name+']').prop("readonly",false);
$('[data-fieldname="'+field.def.name+'"] input[data-type=date]').prop("readonly",false);
}
}, this);
}else{
_.each(this.fields, function(field) {
$('input[name='+field.def.name+']').prop("readonly",false);
$('[data-fieldname="'+field.def.name+'"] input[data-type=date]').prop("readonly",false);
}, this);
}
},
Hope this Helps..!!
Best Regards
S Ramana Raju
The following Gist contains another example that addresses that very use case:
Custom record view controller for setting entire record to read-only conditionally · GitHub
The following Gist contains another example that addresses that very use case:
Custom record view controller for setting entire record to read-only conditionally · GitHub
Hey Angel,
I used your code and it seems to work great, but how do I add an override permission to it to allow changes to be made by an admin incase there is an error in the closing of the opp? Does this make sense?