I'm need set readOnly in custom field when logged user not admin in record.js
if(app.user.get('type') == 'admin') //set readOnly field else //set editable fiel
I'm need set readOnly in custom field when logged user not admin in record.js
if(app.user.get('type') == 'admin') //set readOnly field else //set editable fiel
Hi,
Try
this.$('.record-edit-link-wrapper[data-name=' + field.name + ']').remove();
instead ofself.noEditFields.push(field.name); As this will not work on 7.8.. versions.
Also disable edit and save action.$('.headerpane a[name=edit_button]').addClass("disabled");var self = this;
$('.headerpane a[name=save_button]').addClass("disabled");
_.each(this.model.fields, function(field) {
//self.noEditFields.push(field.name);
this.$('.record-edit-link-wrapper[data-name=' + field.name + ']').remove();
},this);
Regards,
Usman
Thanks Usman,
I found out that your solution is also a good way to do it.
I've got my code working by doing the following:
({
extendsFrom: 'RecordView',
initialize: function (options) {
this._super('initialize', [options]);
this.model.on('sync', _.bind(this._readonlyFields, this));
this._readonlyFields();
},
_renderHtml: function() { //No OPTIONS parameter
var self = this;
self._super('_renderHtml');
},
_readonlyFields: function() {
var self = this;
_.each(self.model.fields, function(field) { //date_closed
self.noEditFields.push(field.name);
$('.record-edit-link-wrapper[data-name=' + field.name + ']').remove(); //remove the little pencil from the field
});
},
_dispose: function() {
this._super('_dispose', []);
}
})
Hi,Usman
this Solution failed ......
Working Normal screen Fine ...
but after press edit button and back browser button then all fields makes editable....
Use the Dependency Framework instead of modifying the record.js. https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_9.3/Architecture/Sugar_Logic/Dependency…
Hi Angel Martinez.
I'm trying to use your method to disable some fields.
I have tabs on my record view, but when using "this.renderHtml();", there ain't nothing tab selected, and the buttons "Cancel", "Save" and "Edit" shows the same time.
Do you have some idea to improve this?
Regards!
Any reason to don't apply dependency ReadOnly?
Hi André!
I need to control some fields depending on various things; current user type, a specific registration status, etc.
But I already made it, using the next code:
hideFields: function(_fieldsArray) {
_fieldsArray.forEach(function(field) {
var element = self.getField(field);
element.setDisabled(true);
});
},
Now, I neet to make read only some subpanels of the record.
Regards.
We had implemented sugarLogic functions which evaluates attributes of authenticated user, like roles, teams, user_name, type etc, so you would be able to invoke such sugarLogic functions in order to decide whether to trigger a ReadOnly action from inside a regular dependency.
Regards
Oh ok!
Could you share me, some example to use these sugarLogic functions inside a regular dependency?
Regards