How set readOnly dynamically in record.js?

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

Parents Reply
  • 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 console
    this.model.attributes.sales_status
    It comes up with "Closed Won", but when I have
    console.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?

Children