Subpanel calculate value from two fields


How to calculate value from two fields in subpanel?


for example:

I have 3 fields in database: field1, field2, field3 and one non-db field4 that i want to calculate

I want see in the subpanel two fields: field1 and field4 calculated in the process_record logic hook as field2 + field3

The problem is, the been that i get in process_record logic hook have value only for field1, and don’t have values for fields field2 and field3

When I add field2 and field3 to list_fields of subpanel_layout, they have values in the logic hook, but if I remove them from list_fields, they haven’t.

So, I need have in list_fields only two fields: field1 and field4, but to calculate field4 also need add field2 and field3, how I can hide the, in subpanel?

Then field2 and field3 I need only in the process_record logic hook been to calculate non db field4

Sorry, about my english.

You need to include those fields as ‘query_only’ in the subpanel definitions.

For example, if the module is Contacts, you would have those definitions in


and fields can either be an actual part of the subpanel (showing as columns) or ‘query_only’ meaning you need to use them but not show them.

Here’s a segment of an example file with one field as ‘query_only’:

$subpanel_layout['list_fields'] = array (
	'first_name' => 
		array (
			'usage' => 'query_only', 
	'photo' =>
	array (
			'name' => 'photo',
			'vname' => 'LBL_PHOTO',
			'width' => '5%',
			'default' => true,

Also, check out the customCode in this same file, it let’s you easily put together field values.

1 Like
'usage' => 'query_only', 

that is what i need, thanks!

but can u explain, what do u mean?

Sorry, I meant check out the customCode field.

You can see a few examples here, and many more on Google:

Basically, you put that into the same subpanel file, like

	array (
			'name' => 'phone',
			'vname' => 'LBL_PHONE',
			'width' => '5%',
			'default' => true,
                        'customCode' => '{$} <span style="color:red;font-style:italic;">Format:+6X X XXXX XXXX</span>',

It uses Smarty syntax. I never found a comprehensive documentation of that syntax, as used in SuiteCRM, so I have trouble using customCode in practice… some things work in subpanels, but not in listviews, some work in detail views, etc.

1 Like

Thanks, good example, will check this functional!