Setting the value of a Related Field in

Hello as I detailed in this post I want to access the information from other modules and put them into the fields. My task is to automatically fill the Accounts field, which takes information from the Accounts Module. I am using Suitecrm 8.4

My question is: What kind of value do I have to return to the field?
So far I have tried passing the id, name and the Bean itself back as a return value none of them have worked so far.

Example what I mean once the Projektpositionen gets filled the Accounts field should automatically get its value.
My code:


namespace App\Extension\eks\modules\eks_maintenance\Service\Fields;

use ApiPlatform\Core\Exception\InvalidArgumentException;
use App\Process\Entity\Process;
use App\Process\Service\ProcessHandlerInterface;
use BeanFactory;
use SugarBean;
use Sugarcrm\Util\LoggerManager;
use App\Engine\LegacyHandler\LegacyHandler;

class SearchContact extends LegacyHandler implements ProcessHandlerInterface
    protected const MSG_OPTIONS_NOT_FOUND = 'Process options are not defined';
    public const PROCESS_TYPE = 'search_contact';
    public const HANDLER_KEY = 'search_contact';

    public function getProcessType(): string
        return self::PROCESS_TYPE;
    public function requiredAuthRole(): string
        return '';

    public function getRequiredACLs(Process $process): array
        return [];

    public function configure(Process $process): void

    public function validate(Process $process): void

    public function getContact($itemid){
        $maintenancebean = BeanFactory::getBean('eks_maintenance',$itemid);
        $maintenancebean -> load_relationship('eks_project_position_eks_maintenance_1');
        $maintenancebean -> load_relationship('eks_project_position');
        $projectpositionid = $maintenancebean -> eks_project_position_eks_maintenance_1 -> get(); // projectid[0] ist der Wert der Relation
        // Wert der Relation ca9273ac-7989-a470-f051-653a95b7f804
        $projectpositionbean = BeanFactory::getBean('eks_project_position',$projectpositionid[0]);
        $projectpositionbean -> load_relationship('eks_project');
        $projectpositionbean -> load_relationship('eks_project_position_eks_projects_1'); // do liegt der Hund begraben us irgend einem Grund findet es bei eks_project_position_eks_projects_1 keine Relation obwohl des us da Vardef kut
        $projectid = $projectpositionbean -> eks_project_position_eks_projects_1 -> get(); // nvmd i bin an schlampiger kopierer
        $projectbean = BeanFactory::getBean('eks_projects',$projectid[0]);
        $projectbean -> load_relationship('eks_projects_accounts_3');
        $accountid = $projectbean -> eks_projects_accounts_3 -> get();
        $accountbean = BeanFactory::getBean('Accounts',$accountid[0]);
        return $accountbean->id;

    public function run(Process $process)
        $options = $process->getOptions();
        $record = $options['record'];
        $recordid = $record['id'];
        $attributes = $record['attributes'];
        $value = $attributes['eks_project_position_eks_maintenance_1_name']['name'];
        $maintenanceid = $attributes['eks_project_position_eks_maintenance_1_name']['id'];
        $contactid = $this->getContact($recordid);
        $responseData = [
            'value' => $contactid


    public function getHandlerKey(): string
        return self::HANDLER_KEY;

Hey @dwaltsch,

From this comment it looks like relate fields aren’t supported on update-value-backend logic:

On the docs it says:

At the moment this does not work for relate fields

Though, maybe there is another way to do it without using field ‘logic’ entry

1 Like

Thanks for the reply guess I’ll try to save the data directly to the bean and update to see if it works

There is a bit of a hack I have discovered :smiley:

If you place the id field of the relate field on the page not sure what you r accounts relate field is called but say its somehting like this:


if you check your vardefs you will have a field like accounts_id_c, this holds the ID of the related account.

So put that on the page somewhere (a tab that you never view for example). Then add your Process logic to that field (so it does your backend logic and that returns just the ID into this field). When you save, it will save everything with your linked account. It doesnt update the nice picker box live (it will when you save), however this field will be updated automatically if you use the picker box.

This will all need to be done in your detailviewdefs.php file obviously.

(hope that makes sense)