Iâm trying to set the Account Number field to read only for non Admins. I added the following code to \custom\modules\accounts\metadata\detailviewsdef.php but the Account Number field still shows as being editable in the Accountâs detail view. I successfully changed the EditView to show the account number as read only for non-Admins but canât figure out how to change the DetailView screen to read only.
This is how my detailviewdefs.php starts:
<?php
$viewdefs ['Accounts'] =
array (
'DetailView' =>
array (
'templateMeta' =>
array (
'form' =>
array (
'buttons' =>
array (
0 => 'EDIT',
1 => 'DUPLICATE',
2 => 'DELETE',
3 => 'FIND_DUPLICATES',
'AOS_GENLET' =>
array (
'customCode' => '<input type="button" class="button" onClick="showPopup();" value="{$APP.LBL_GENERATE_LETTER}">',
),
),
),
'maxColumns' => '2',
'widths' =>
array (
0 =>
array (
'label' => '10',
'field' => '30',
),
1 =>
array (
'label' => '10',
'field' => '30',
),
),
'includes' =>
array (
0 =>
array (
'file' => 'modules/Accounts/Account.js',
),
),
'useTabs' => false,
'tabDefs' =>
array (
'LBL_ACCOUNT_INFORMATION' =>
array (
'newTab' => false,
'panelDefault' => 'expanded',
),
'LBL_EDITVIEW_PANEL1' =>
array (
'newTab' => false,
'panelDefault' => 'expanded',
),
'LBL_PANEL_ADVANCED' =>
array (
'newTab' => false,
'panelDefault' => 'collapsed',
),
),
'syncDetailEditViews' => true,
),
'panels' =>
array (
'lbl_account_information' =>
array (
0 =>
array (
0 =>
array (
'name' => 'name',
'comment' => 'Name of the Company',
'label' => 'LBL_NAME',
),
1 =>
array(
'name' => 'account_number',
'comment' => 'The client account number',
'label' => 'Account_Number',
'type' => 'readonly',
'customCode' => '{if $IS_ADMIN}@@FIELD@@{else}{$fields.account_number_c.value}{/if}',
),
/*
1 =>
array (
'name' => 'account_number_c',
'label' => 'LBL_ACCOUNT_NUMBER',
),
*/
etc
Thanks for your help - greatly appreciated.