I have a custom module with 3 sub-modules. 2 of them have identical multi-select fields named âtestingâ. The third module includes a one to many relationship with the second module. Once that relationship is added, an after_relationship_add triggers the following code:
<?php
if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
class EquipmentUpdate
{
function TestingLink($bean, $event, $arguments)
{
if($arguments['related_module'] == "INV_Inv_Type") {
$bean->testing = $arguments["related_bean"]->testing;
}
}
}
?>
which sets the 3rd module testing field equal to the 2nd module testing field. This works correctly and as soon as I hit save, the inherited testing information shows up on the screen. I would like to have the testing information populate as soon as the relationship is added.
Most of the information about refreshing on-screen values is based on a custom controller. However, unless I am mistaken, that wonât work here because the record hasnât been saved yet so there is no record to retrieve. So I am thinking I need to add the js directly to the php function called by after_relationship_add but I am not sure what the right code is.
The closest thing I have found is:
$model = BeanFactory::getBean($_REQUEST["module"], $_REQUEST["record"]);
$field_to_update = "testing";
$field_value = $model->testing;
$js=<<<EOQ
<script>
$( document ).ready(function() {
document.querySelector('div[type="enum"][field="$field_to_update"]').innerHTML = "$field_value";
});
</script>
EOQ;
echo $js;
but I havenât been able to figure out how to make it work with a multi-select field and I noticed that the viewdefs have specific code for multi-select fields so perhaps I need to be referencing a standard function rather than modifying the innertext but I donât know what it is.
Thanks a lot
SuiteCRM version 7.11.15