How to make a custom field read only in detail view??
Thanks!!
How to make a custom field read only in detail view??
Thanks!!
Hi sugardeveloper11,
Do you want to make a field as readonly in 'Detail view'?
This is just example:
1) Copy the file (only if it does not exist) from modules\Accounts\clients\base\views\record\record.php to custom\modules\Accounts\clients\base\views\record\record.php
2) Find your field in this file (for example: [industry])
3) replace
'industry',
by
array( 'name' => 'industry', 'readonly' => true, ),
Hi Roman,
This will make the field readonly only in record view. But users will be able to edit the field from list view and sub-panel list view in this case.
If I am not mistaken, the question is: "How to make a custom field read only in detail view ??"
hey roman , thanks alot, your solution works great!!
Changes you made in record.php will be overwritten once you deploy the the record view layout again in studio. Its a know bug in sugar!
I believe that was corrected in 7.5.
Hi All Developers,
i have the same issue, i have applied readonly option to my custom field in verdef
it is working fine, but in list view user are able to edit the field.
could you please suggest me the solution, i need also to readonly the field on list view
Any suggestions would be appreciated.
Hello Technical Team,
You go to this path /custom/modules/<your ModuleName>/clients/base/views.
If the "recordlist" folder exists within the specified path, and if that folder contains the "recordlist.js" file, it is necessary to incorporate custom code. Conversely, if the "recordlist" folder is not present, you must create this folder within the "views" directory. Subsequently, inside the newly created "recordlist" folder, include a file named "recordlist.js." This process ensures the proper organization and inclusion of the required files for the intended functionality.
After that, you need to add some code here({
extendsFrom: 'RecordlistView',
initialize: function (options) {
this._super('initialize', [options]);
this.listenTo(this.collection, 'data:sync:complete', this.listViewFieldReadonly);
},
listViewFieldReadonly: function () {
_.each(this.meta.panels, function (panel) {
_.each(panel.fields, function (field) {
if (field.name == "custom_fieldName") {
field.readonly = true;
}
});
});
},
})
Alternatively, you can achieve the same outcome through the studio. Navigate to "Admin -> Studio -> <Your ModuleName> -> Fields -> <Your fieldName>." Within this section, uncheck the "Mass Update" option. Subsequently, observe an option labeled "Required Field" that appears just beneath; check this box. Finally, save the field configuration. This process will automatically render the field as read-only across all relevant areas.
Hope this will work for you.
Kishan Singh Thank you so much for your support
Kishan Singh
i have tried the above solution in my local development system, but my custom field is still editable on list view, what should i do now, please suggest
Hello Technical Team,
It seems like you're encountering a challenge with your custom field's editability on the list view despite implementing the provided solution in your local development system.
Have you tried this
Alternatively, you can achieve the same outcome through the studio. Navigate to "Admin -> Studio -> <Your ModuleName> -> Fields -> <Your fieldName>." Within this section, uncheck the "Mass Update" option. Subsequently, observe an option labeled "Required Field" that appears just beneath; check this box. Finally, save the field configuration. This process will automatically render the field as read-only across all relevant areas.
Or you want to add the read-only to the field using code.
Hello Technical Team,
It seems like you're encountering a challenge with your custom field's editability on the list view despite implementing the provided solution in your local development system.
Have you tried this
Alternatively, you can achieve the same outcome through the studio. Navigate to "Admin -> Studio -> <Your ModuleName> -> Fields -> <Your fieldName>." Within this section, uncheck the "Mass Update" option. Subsequently, observe an option labeled "Required Field" that appears just beneath; check this box. Finally, save the field configuration. This process will automatically render the field as read-only across all relevant areas.
Or you want to add the read-only to the field using code.