Transfer data from detailview to quickcreate

Hi, as per the subject I have a custom module that is linked in a relation with another custom module, so I have the main panel and the subpanel below.
Since some fields between the two are the same, I would like the common ones to be already filled in when I do a quickcreate.
So far I have always acted in this way:

'customCode' => '<input type="text" value = "{$fields.<relationship>_name.value}" id = "name" name = "name" readonly="readonly">',

put inside the quickcreatedefs or the detaildefs or the editdefs, but now I need to recover other fields.
Do you know how I can do it? Thanks.

Does anyone know how I can fix this?

You use logic hook to do it? What is your version?

custom/modules/ModuleA/logic_hooks.php

$hook_array['before_save'][] = Array(
    1, 
    'Populate related fields', 
    'custom/modules/ModuleA/logic_hooks/PopulateRelatedFields.php', 
    'PopulateRelatedFields', 
    'populateFields'
);

custom/modules/ModuleA/logic_hooks/PopulateRelatedFields.php

class PopulateRelatedFields {
    function populateFields($bean, $event, $arguments) {

        if (!empty($bean->module_a_id)) {

            $moduleA = BeanFactory::getBean('ModuleA', $bean->module_a_id);
            
            $bean->email = $moduleA->email;
            $bean->phone = $moduleA->phone;
            $bean->address = $moduleA->address;
        }
    }
}

In this case the logic hooks are of little use, I need to make the data appear when I activate the quick create.
the best way is to act on quickcreatedfs but I don’t know how to recover all the data I need.
I also tried to create the view.quickcreate.php file and use assign, but it seems that the file is not executed at all.
I’m trying everything but I have no results.
The suite version is 8.4.2

I don’t know if there is a better or more SuiteCRM-compliant way, but I solved the problem by managing to intercept the parent id of the subpanel, then I retrieved the module bean I needed and the information I needed, all this inside quickcreatedefs.

That’s awesome! Could you please share your solution here? It will help others inn the future.

certainly:
I will try to go into more detail. As said above I took the quickcreatedefs.php file of my custom module (the subpanel from which to click the “create” button) and at the top I inserted these instructions

$bean_module=BeanFactory::getBean('<MY_PARENT_MODULE>',$_REQUEST['<my_parent_module>_id']);

once I got the bean of the parent module it is easy to get the data I needed

$last_name=$bean_module->last_name;
...

then I inserted, inside the reference field below (always in the same file):

'customCode' => '<input type="text" value = "'.$last_name.'" id = "last_name_c" name = "last_name_c" readonly="readonly">',

and finally a Quick & Repair

1 Like