Readonly Dependency Half Working

Hi everyone.

I am having an issue where I have created a readonly dependncy but it's only working on some of the fields but not all, has anyone had this? My dependency file lives here: custom/Extension/modules/Contacts/Ext/Dependencies/pp_readonly.php

In the snipper below, pp_id_c is not readonly but pp_api_result_c is, and in the second lot of fields, everything above the "not working" works.

Does anyone have any ideas as it's baffling me? I've checked the right names and tried it without an array and it just doesn't work.

Thanks!


Daniel

<?php
$readonly_fields = array(
	'pp_api_result_c',
	'pp_id_c'
);

foreach($readonly_fields as $field)
{
	$dependencies['Contacts']['readonly_fields_always_'.$field] = array(
		'hooks' => array("edit","all"),
		'trigger' => 'true',
		'onload' => true,
		'actions' => array(
			array(
				'name' => 'ReadOnly',
				//The parameters passed in will depend on the action type set in 'name'
				'params' => array(
					'target' => $field,
					'value' => 'true',
				),
			),
		),
	);
}

$readonly_fields = array(
	'salutation',
	'first_name',
	'last_name',
	'primary_address_street',
	'primary_address_city',
	'primary_address_state',
	'primary_address_postalcode',
	'primary_address_country',
	'phone_work',
	'phone_mobile',
	'email',
	//Not working
	'pp_type_c',
	'pp_branch_c',
	'pp_branch_area_c',
	'pp_start_date_c',
	'pp_service_priority_c'
);

foreach($readonly_fields as $field)
{
	$dependencies['Contacts']['readonly_fields_ppid_'.$field] = array(
		'hooks' => array("edit","all"),
		'trigger' => 'true',
		'onload' => true,
		'actions' => array(
			array(
				'name' => 'ReadOnly',
				//The parameters passed in will depend on the action type set in 'name'
				'params' => array(
					'target' => $field,
					'value' => 'greaterThan(strlen($pp_id_c),0)',
				),
			),
		),
	);
}

Parents
  • Can you make sure there is not either dependency or formula configured through Studio for those fields?

    André Lopes
    Lampada Global
    Skype: andre.lampada
  • Hi Andre.

    Thanks you were absolutely right the pp_id_c field had a dependent in studio. I've tried to move it to the dependency file but now the readonly + visbility both aren't working. Do you know if you can chain them like so?

    $readonly_fields = array(
    	'pp_api_result_c',
    	'pp_id_c'
    );
    
    foreach($readonly_fields as $field)
    {
    	$dependencies['Contacts']['readonly_fields_always_'.$field] = array(
    		'hooks' => array("edit","all"),
    		'trigger' => 'true',
    		'onload' => true,
    		'actions' => array(
    			array(
    				'name' => 'ReadOnly',
    				//The parameters passed in will depend on the action type set in 'name'
    				'params' => array(
    					'target' => $field,
    					'value' => 'true',
    				),
    			),
    			array(
    				'name' => 'SetVisibility',
    				//The parameters passed in will depend on the action type set in 'name'
    				'params' => array(
    					'target' => $field,
    					'value' => 'equal($send_to_peopleplanner_c,"Yes")',
    				),
    			),
    		),
    	);
    }
    

Reply
  • Hi Andre.

    Thanks you were absolutely right the pp_id_c field had a dependent in studio. I've tried to move it to the dependency file but now the readonly + visbility both aren't working. Do you know if you can chain them like so?

    $readonly_fields = array(
    	'pp_api_result_c',
    	'pp_id_c'
    );
    
    foreach($readonly_fields as $field)
    {
    	$dependencies['Contacts']['readonly_fields_always_'.$field] = array(
    		'hooks' => array("edit","all"),
    		'trigger' => 'true',
    		'onload' => true,
    		'actions' => array(
    			array(
    				'name' => 'ReadOnly',
    				//The parameters passed in will depend on the action type set in 'name'
    				'params' => array(
    					'target' => $field,
    					'value' => 'true',
    				),
    			),
    			array(
    				'name' => 'SetVisibility',
    				//The parameters passed in will depend on the action type set in 'name'
    				'params' => array(
    					'target' => $field,
    					'value' => 'equal($send_to_peopleplanner_c,"Yes")',
    				),
    			),
    		),
    	);
    }
    

Children
No Data