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:
<?php
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
{
$process->setId(self::PROCESS_TYPE);
$process->setAsync(false);
}
public function validate(Process $process): void
{
}
public function getContact($itemid){
$this->init();
$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]);
$this->close();
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
];
$process->setStatus('success');
$process->setMessages([]);
$process->setData($responseData);
}
public function getHandlerKey(): string
{
return self::HANDLER_KEY;
}
}