AnsweredAssumed Answered

Create new records from multiselect value

Question asked by Erik Hallin on Oct 11, 2016
Latest reply on Oct 13, 2016 by Francesca Shiekh

Hello,

I want to create new records in another module using the names in a multiselect field. I have tried using this code but it doesn't work. Any help would be appreciated.

 

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

class CreateProducts
{
    function CreateNewProducts($bean, $event, $arguments)
    {

        $fieldname = 'produktval_c';
        $productNames = unencodeMultienum($bean->produktval_c);


        array_walk($productNames, function($val) use($bean,$fieldname)
        {
            $val = $GLOBALS['app_list_strings'][$bean->field_defs[$fieldname]['options'][$bean->$fieldname]];
            $GLOBALS['log']->fatal(print($val));

            $ProduktBean = BeanFactory::getBean("EGBS_Produkter");
            $ProduktBean->name = $val;
            $ProduktBean->save();

        });

    }

}

 

Regards

Erik 

Outcomes