Cases subpanel - Auto fill fields

I have Cases subpanel in the opportunities module. Now, I want to fill up some fields of cases auto filled while it is created from the opportunity subpanel.

I want to auto fill fields like work number and customer name (these fields are custom fields)

Is it possible to achieve it? If yes, how to do it? Let me know if my question is not clear enough!

Never mind! I found out. I created a before_save logic hook to do it.

<?php
if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

class AutoFillFields {
    function autoFillFieldsMethod($bean, $event, $arguments) {
   
        $opportunity_id = $bean->opportunity_id;
        
        if (!empty($opportunity_id)) {
            
            $opportunity = BeanFactory::getBean('Opportunities', $opportunity_id);
            
            $bean->account_name = $opportunity->account_name;
            $bean->opportunity_name = $opportunity->name;
            $bean->work_number = $opportunity->phone_work;
        }
    }
}

1 Like