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
You should be able to adapt this Gist to do what you want:
Custom record view controller for setting entire record to read-only conditionally · GitHub
They key is to add the field name into the "noEditFields" array.
Hi
This code works for me in 7.8 when I pause it at breakpoints. However it appears that this javascript is running before the model has been loaded, hence I get
this.model.attributes.sales_status is undefined
When I run it without breakpoints.
When I insert a breakpoint and type in the javascript consolethis.model.attributes.sales_status
It comes up with "Closed Won", but when I haveconsole.log(this.model.attributes.sales_status)
it just prints undefined.
Is there a way to make sure this only runs once the model has been fully loaded?
Also is it preferred to set fields to readonly using this method or sugarlogic dependencies?
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
Hi,Usman
this Solution failed ......
Working Normal screen Fine ...
but after press edit button and back browser button then all fields makes editable....
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…