This topic contains 0 replies, has 1 voice, and was last updated by zhex900 6 years, 7 months ago.
- Topic
Hi,
How do I set workflow transit parameters in the code.
Here is my transition definition:
123456789101112131415161718192021222324#workflow.ymltransition_definitions:assign_def:# Either auto allocate have value or assigned have value.# Both cannot have value. One have to be null.conditions:# ($assignedTo not empty AND $auto_allocate is false) OR# ($assignedTo is empty AND $auto_allocate is true)'@or':- '@and':message: You must select either Assigned to or Auto allocate. But you cannot select both.parameters:- '@not_empty': [$assigned_to]- '@equal': [$auto_allocate,false]- '@and':parameters:- '@empty': [$assigned_to]- '@equal': [$auto_allocate,true]actions:- '@auto_allocate_workflow':assigned_to: $assigned_toowner: $ownerentity_class: $.entityauto_allocate: $auto_allocateThis is what I use to transit.
123456789101112131415161718192021222324252627282930313233/*** find the current step name of follow up workflow* @param Contact $contact* @param string $workflow* @return WorkflowItem*/public function getCurrentWorkFlowItem(Contact $contact, $workflow){$workflowItems = $this->getWorkflowItemsByEntity($contact);if (0 !== count($workflowItems)) {/** @var WorkflowItem $workflowItem */$workflowItem = array_shift($workflowItems);//find the follow-up workflowif (preg_match('/'.$workflow.'/', $workflowItem->getWorkflowName())) {return $workflowItem; //->getCurrentStep()->getName();}}}/** @param Contact $contact* name of the workflow* @param string $workflow* name of the transition* @param string|Transition $transition*/public function transitTo(Contact $contact, $workflow, $transition){file_put_contents('/tmp/tag.log',$contact->getFirstName().' '.$contact->getLastName().' transit to '.$transition. PHP_EOL, FILE_APPEND);$workflowItem = $this->getCurrentWorkFlowItem($contact, $workflow);$this->transit($workflowItem,$transition);}This works fine when I do not have conditions in the transition definition. I guess the transition condition failed. Is there a way to transit even if the condition fail?
One solution is I can set the transition parameter. For example $assigned_to= some value.
But how do I do that?
The forum ‘OroPlatform – How do I? Questions’ is closed to new topics and replies.