Hi @yuriseki,
The Fetch entity variable by id action is not working for Target Entity Type group.
While trying to fetch an entity variable of type group by id, the following error is displayed:
Error: Call to a member function getFieldDefinition() on null in Drupal\business_rules\Plugin\BusinessRulesAction\FetchEntityVariableAction->processVariables() (line 155 of \modules\contrib\business_rules\src\Plugin\BusinessRulesAction\FetchEntityVariableAction.php)
UPDATE:
I noticed this error is displayed due two reasons:
1) When trying to fetch two different entities in the same "rule event".
AND
2) When the "Fetch entity variable by ID" for the "group" content is re-ordered to the end of the of the "rule event".
For example, the below rule structure will display the above error and only the article entity will be fetched, updated and saved:
Reacts on event: Entity insert.
Actions to fetch and save an Article entity:
Fetch entity variable by id (Article)
Set values to entity variable (Article)
Save entity variable (Article)
Actions to fetch and save a Group entity:
Fetch entity variable by id (Group)
Set values to entity variable (Group)
Save entity variable (Group)
However, the below rule structure will not display any error and both entities will be successfully fetched, updated and saved:
Reacts on event: Entity insert.
Actions to fetch and save a Group entity:
Fetch entity variable by id (Group)
Set values to entity variable (Group)
Save entity variable (Group)
Actions to fetch and save an Article entity:
Fetch entity variable by id (Article)
Set values to entity variable (Article)
Save entity variable (Article)
The complete error:
The website encountered an unexpected error. Please try again later.
Error: Call to a member function getFieldDefinition() on null in Drupal\business_rules\Plugin\BusinessRulesAction\FetchEntityVariableAction->processVariables() (line 155 of modules\contrib\business_rules\src\Plugin\BusinessRulesAction\FetchEntityVariableAction.php).
Drupal\business_rules\Plugin\BusinessRulesAction\FetchEntityVariableAction->processVariables(Object, Object) (Line: 113)
Drupal\business_rules\Plugin\BusinessRulesAction\FetchEntityVariableAction->execute(Object, Object) (Line: 97)
Drupal\business_rules\Entity\Action->execute(Object) (Line: 474)
Drupal\business_rules\Util\BusinessRulesProcessor->executeAction(Object, Object) (Line: 316)
Drupal\business_rules\Util\BusinessRulesProcessor->processTriggeredRules(Array, Object) (Line: 168)
Drupal\business_rules\Util\BusinessRulesProcessor->process(Object) (Line: 136)
Drupal\business_rules\EventSubscriber\BusinessRulesListener->process(Object, 'business_rules.entity_insert', Object)
call_user_func(Array, Object, 'business_rules.entity_insert', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('business_rules.entity_insert', Object) (Line: 115)
business_rules_entity_insert(Object)
call_user_func_array('business_rules_entity_insert', Array) (Line: 403)
Drupal\Core\Extension\ModuleHandler->invokeAll('entity_insert', Array) (Line: 206)
Drupal\Core\Entity\EntityStorageBase->invokeHook('insert', Object) (Line: 756)
Drupal\Core\Entity\ContentEntityStorageBase->invokeHook('insert', Object) (Line: 507)
Drupal\Core\Entity\EntityStorageBase->doPostSave(Object, ) (Line: 641)
Drupal\Core\Entity\ContentEntityStorageBase->doPostSave(Object, ) (Line: 917)
Drupal\webform\WebformSubmissionStorage->doPostSave(Object, ) (Line: 432)
Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 774)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object) (Line: 390)
Drupal\Core\Entity\Entity->save() (Line: 756)
Drupal\webform\Entity\WebformSubmission->save() (Line: 1608)
Drupal\webform\WebformSubmissionForm->save(Array, Object)
call_user_func_array(Array, Array) (Line: 111)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 51)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 589)
Drupal\Core\Entity\EntityFormBuilder->getForm(Object, 'test') (Line: 992)
Drupal\webform\Entity\Webform->getSubmissionForm(Array, 'test') (Line: 78)
Drupal\webform\Controller\WebformTestController->testForm(Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 669)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)Thank you,
Comments
Comment #2
c.e.a commentedComment #3
c.e.a commentedComment #4
c.e.a commentedComment #5
c.e.a commented