Process_record_hook in SuiteCRM

Hooks provide an additional feature i.e. we can add custom code functionality to SuiteCRM. There are many types of hooks available in suiteCRM.
process_record is one of the module logic hook which has very amazing functionality…Let’s see how.

According to the Definition,

Fired when a record is processed ready to be displayed in list views or dashlets.”

Basically process_record is the only logic hook executes when the record is being processed as a part of the ListView or subpanel list. Consider as example, in list view of Account Module We want to append “Acc_” to eavery record name field value. But we dont want to store this in the database. Every time when account module will load, each name field value will be prefixed with “Acc_”.

Click Here to see the detailed example with code snippet.

Another example of process_record hook is, consider in the list view of the Leeds module, we want to distinguish the Leads based on the status. e.g. if the lead is in open state then it should be highlighted with green color. If it is in processing then it should be “yellow”. So this type of visual effect can be given using process_record hook.

I tried to use your link but it’s dead. Please fix your link or remove it from your post.

Thanks,

BrozTechnologies

Hi @BrozTechnologies,

Actually my site DB dropped. Please find the solution here.

1 Like

Thanks,

BrozTechnologies

Hello - great article, I have noticed that if a custom field is hidden on the list view (i.e. the “Choose columns”) then, the custom field value is not available in the bean. If I add the field to the list view, then I can get the value of that field with the bean.

Do you know if there is a way to get the value of a custom field to work with on the bean without having to show it on the list view? For example, if you are wanting to color a field that IS shown on the list view but it is based on a field calculation from a custom field that is hidden from the list view. Hope this question makes sense!

Google for SuiteCRM examples containing the expression “query_only”

That’s is a way to reference a field in the view defs without showing it in the UI, just so it can be used somewhere else. It basically ensures that the field gets loaded, which I think is what you’re asking for.

1 Like

In your example could you do something like: if (lets say lead status) = new then

"<div style="color:red;">.$bean->status."</div>";

if status = contacted
"<div style="color:green;">.$bean->status."</div>";

I guess what I’m asking is the function like a while loop that goes through the records one by one and appends/prepends each record or does it have to apply to all records in the list?

Looks like the query_only parameter was only for subpanels. I couldn’t get it to work for listview defs.

Cool Just answered my own Question. Works great!!! This is so cool.

<?php
class HighlightStatusLogicHook{

    public function highlightStatus(SugarBean $bean, $event, $arguments){
        //$colour = substr(md5($bean->status),0,6);
		if(	$bean->status=="New")
			$bean->status = "<div style='border: solid 5px #F08377; text-align:center;'>".$bean->status."</div>";
		elseif($bean->status=="Converted")
			$bean->status = "<strike>".$bean->status."</strike>";

    }
}
?>

@swihtlow I did it slightly differently, I did it like this:

https://docs.suitecrm.com/blog/listview-conditional-formatting/

1 Like