Beans and Arrays for condional formatting

I used a guide from Jim Mackin to do this but now I need a bit more help.
http://www.jsmackin.co.uk/suitecrm/suitecrm-list-view-conditional-formatting/

When I have a “Terminated” employee I want all the values returned in the list view to have a strikethrough so that it stands out to all users. I have got it to work, see below, but what I would like to do is cycle through all the returned values using an array or foreach and apply the formatting , rather than specify each field. Can anyone advise me?

<?php
class StrikethroughLogicHook{
    
    public function strikethroughName(SugarBean $bean, $event, $arguments)
    {
    if($bean->employee_status=="Terminated"){$bean->employee_status = "<div style='color: red;'><del>".$bean->employee_status."</del></div>";
    $bean->title = "<div style='color: red;'><del>".$bean->title."</del></div>";
        } 
    else {$bean->employee_status = $bean->employee_status;
    }
}
}

`

Is that in a process_record hook?

I don’t think it is possible to do this kind of HTML formatting except in the way you’re currently doing it. There is no place (hook or point in code) where you take in all rows at the same time, to do output formatting work.

But I don’t see any disadvantage of doing it like this. Your code should work well and be reasonably lightweight.

You could override the whole View class, but it’s not going to be worth the trouble…

1 Like