Forums › Forums › OroCRM › Create Workflow via bin/console oro:workflow:definition: Entity not Available
This topic contains 13 replies, has 2 voices, and was last updated by Ilya Antypenko 4 years, 9 months ago.
Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.
- CreatorTopic
- June 3, 2019 at 4:02 am #39000
Hi there,
I am trying to get Workflow-Demo-Example into work:
https://github.com/oroinc/platform/blob/master/src/Oro/Bundle/WorkflowBundle/Resources/doc/reference/workflow/configuration-reference.md#example-workflow-configuration1)
I created a new bundle, and enabled it (checked with Web-Profiler)PHP12345678910<?php// src/Acme/Bundle/DemoWorkflowBundle/AcmeDemoWorkflowBundle.phpnamespace Acme\Bundle\DemoWorkflowBundle;use Symfony\Component\HttpKernel\Bundle\Bundle;class AcmeDemoWorkflowBundle extends Bundle{}2)
Within this Bundle, I created two new entities (according to the DemoExample-description above):
Acme\Bundle\DemoWorkflowBundle\Entity\PhoneCall.php
Acme\Bundle\DemoWorkflowBundle\Entity\PhoneConversation.php3)
I coded 2 migrations manually (as described in
https://oroinc.com/orocrm/doc/current/dev-guide/entities/creating-entities):Acme\Bundle\DemoWorkflowBundle\Migrations\Schema\v1_0\PhoneCall.php, and
Acme\Bundle\DemoWorkflowBundle\Migrations\Schema\v1_0\PhoneConversation.php4)
The migrations were migrated withPHP1bin/console oro:migration:load --forceRESULT:
Tabled are created in the right way (checked with phpMyAdmin)5)
Workflow config-files were put into my Bundle directory (again, as described in the DemoWorkflow-example, see link on the top of this thread):
Acme\Bundle\DemoWorkflowBundle\Resources\config\oro\workflows.yml
Acme\Bundle\DemoWorkflowBundle\Resources\translations\workflows.en.yml6)
Workflow was load, with:PHP1.bin/console oro:workflow:definitions:loadRESULTS:
– Workflow was loaded. It shows up in the list of available workflows (Backend > System > Workflows …)
with its name,
and related entity: Acme\Bundle\DemoWorkflowBundle\Entity\PhoneCallQUESTION 1:
– In the single Workflow view shown things, RELATED ENTITY is NOT AVAILABLE
– Looking into the list of available entities via Backend > system > Entities > Entitymanager, both new entities PhoneCall and PhoneConversation are not listed.
What is going on here?QUESTION 2:
In workflows.yml
init_entities are set to:
– ‘Oro\Bundle\UserBundle\Entity\User’, and
– ‘Oro\Bundle\TaskBundle\Entity\Task’Trying to test the workflow from
– Backend > System > Users > [some single user], or
– Backend > System > Tasks > [some single task]
It shows some workflows buttons, however, they are not clickable, and labels are, like
‘oro.workflow.phone_call.transisition.start_call.label’It should be clickable at first, and should be labeled correctly with
‘Start Phone Call’
as configured in workflows.en.yml.Message Consumers are running (checked)!
What is wrong with ENTITIES and WORKFLOW-Labels here?
Thanks a lot for urgent help
Frank - CreatorTopic
- AuthorReplies
- June 3, 2019 at 4:06 am #39001
This is, how the translation config file workflows.en.yml lookes like:
PHP12345678910111213141516171819202122232425262728293031323334353637oro:workflow:phone_call:label: 'Demo Call Workflow'step:start_call:label: 'Start Phone Call'start_conversation:label: 'Call Phone Conversation'end_call:label: 'End Phone Call'attribute:phone_call:label: 'Phone Call'call_timeout:label: 'Call Timeout'call_successfull:label: 'Call Successful'conversation_successful:label: 'Conversation Successful'conversation_comment:label: 'Conversation Comment'conversation_result:label: 'Conversation Result'conversation:label: Conversationtransition:connected:label: Connectedwarning_message: 'Going to connect...'not_answered:label: 'Not answered'end_conversation:label: 'End conversation'attribute:conversation_comment:label: 'Comment for the call result'June 3, 2019 at 4:15 am #39002And, this is workflows.yml config file, last not least.
PHP123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122workflows:phone_call:entity: Acme\Bundle\DemoWorkflowBundle\Entity\PhoneCallstart_step: start_callsteps:start_call:allowed_transitions:- connected- not_answeredstart_conversation:allowed_transitions:- end_conversationend_call:is_final: trueattributes:phone_call:type: entityoptions:class: Acme\Bundle\DemoWorkflowBundle\Entity\PhoneCallcall_timeout:type: integercall_successfull:type: booleanconversation_successful:type: booleanconversation_comment:type: stringconversation_result:type: stringconversation:type: entityoptions:class: Acme\Bundle\DemoWorkflowBundle\Entity\PhoneConversationvariable_definitions:variables:var1:type: 'string'value: 'Var1Value'transitions:start_call:is_start: true # this transition used to start new workflowstep_to: start_conversation # next step after transition performingtransition_definition: create_call # link to definition of conds & post actionsinit_context_attribute: init_source # name of variable which contains init contextinit_entities: # list of view page entities# where will be displayed transition button- 'Oro\Bundle\UserBundle\Entity\User'- 'Oro\Bundle\TaskBundle\Entity\Task'init_datagrids: # list of datagrids on which rows start# transition buttons should be shown for# start transition from not related entity- user_entity_grid- task_entity_gridconnected:step_to: start_conversationtransition_definition: connected_definitionnot_answered:step_to: end_calltransition_definition: not_answered_definitionend_conversation:step_to: end_callform_options:attribute_fields:conversation_comment:options:transition_definition: end_conversation_definitiontransition_definitions:create_call:conditions: # Check that the transition start from the entity page'@and':- '@not_empty': [$init_source.entityClass]- '@not_empty': [$init_source.entityId]actions:- '@find_entity':class: $init_source.entityClassidentifier: $init_source.entityIdattribute: $.user- '@tree':conditions:- '@instanceof': [$init_source.entityClass,'Oro\Bundle\UserBundle\Entity\User']actions:- '@assign_value': [$entity.phone, $.user.phone]- '@flush_entity': $entity # flush created entityconnected_definition: # Try to make call connected# Check that timeout is setconditions:'@not_blank': [$call_timeout]# Set call_successfull = trueactions:- '@assign_value':parameters: [$call_successfull, true]not_answered_definition: # Callee did not answer# Make sure that caller waited at least 60 secondsconditions: # call_timeout not empty and >= 60'@and':- '@not_blank': [$call_timeout]- '@ge': [$call_timeout, 60]# Set call_successfull = falseactions:- '@assign_value':parameters: [$call_successfull, false]end_conversation_definition:conditions:# Check required properties are set'@and':- '@not_blank': [$conversation_result]- '@not_blank': [$conversation_comment]- '@not_blank': [$conversation_successful]# Create PhoneConversation and set it's properties# Pass data from workflow to conversationactions:- '@create_entity': # create PhoneConversationparameters:class: Acme\Bundle\DemoWorkflowBundle\Entity\PhoneConversationattribute: $conversationdata:result: $conversation_resultcomment: $conversation_commentsuccessful: $conversation_successfulcall: $phone_callJune 4, 2019 at 5:47 am #39013Hi Frank.
> QUESTION 1:
Please check that you run bin/console cache:clear --env=prod to clear caches for production environment (CLI commands run in dev env, when web requests are handled in prod env by default)
> QUESTION 2:
> like ‘oro.workflow.phone_call.transisition.start_call.label’You need to create translation for this button.
Something like this: https://github.com/oroinc/orocommerce/blob/c2bc3f4257f6d3bc60eded141d0041dd1b882fe0/src/Oro/Bundle/CheckoutBundle/Resources/translations/workflows.en.yml#L8I don’t see key you mentioned here in your workflows.en.yml file. Please check it.
I see that you have start_call.label in step section, but you need to have it in transition section as well> It shows some workflows buttons, however, they are not clickable, and labels are, like
Verify that your role has permissions to interact with this workflow.
You can find this settings on the Roles view page in Workflows sectionJune 4, 2019 at 10:41 am #39016Hi Ian,
thanks for reply.
QUESTION 1:
command
bin/console cache:clear –env=proddoes not work, unfortately. Entities have been migrated to mysql-db correctly, but they are not listed in
backend > system > entities > manage entities.—
Creating other entities within my own bundles
/src/Avme/DemoBundle/ …creates DB-tables as well, but entity is not listed in
backend > system > entities > manage entities.What I am doing wrong?
Thanks for help
FrankJune 5, 2019 at 1:08 am #39019Do your entities have @Config annotation?
It’s needed to make this entity configurable and available from Entity Management UI.Please check documentation here:
https://github.com/oroinc/platform/tree/1af2f879d74d52c8ff01cfbe93b0568b230ed362/src/Oro/Bundle/EntityConfigBundle#oroentityconfigbundleExample of usage:
https://github.com/oroinc/OroCRMTaskBundle/blob/48622b405dce7c7288b8fb17afe1fb0bd249dc16/Entity/Task.php#L31June 5, 2019 at 1:32 am #39020Hi Ilya,
ok, this seems to be the right way …
Yes, indeed, my entities have @config annotations, but the are ’empty’:
PHP12345/*** @ORM\Entity* @ORM\Table(name="acme_some_table_name")* @Config*/It seems, I have to specify (=expand) @config annotation within Entity-class-definition as shown in your usage-example above ..?!
—
OR, can I use ’empty’ @config annotation PLUS /oro/config/entity_config.yml
in my bundle AS WELL?
(Trying this second way, I wasn’t successful until now)Thanks a lot.
FrankJune 5, 2019 at 1:44 am #39021Hi Ilya,
doc is very helpful!!!! Thank you. I gonna read it first, think it will help to solve my problem.
Kind regrads
FrankJune 5, 2019 at 1:55 am #39023You are welcome.
Configuration in oro/config/entity_config.yml is used to create your own entity configs. As I understand it’s not what you want right now.
Empty @Config() should be ok, just check that you have
use Oro\Bundle\EntityConfigBundle\Metadata\Annotation\Config; in your file.If it doesn’t help you. Please share your entity php file
June 5, 2019 at 6:34 am #39025Hi Ilya,
I tried to define some config-parameters for a single Demo-Entity ‘Hotel’:
PHP12345678910111213141516171819202122232425<?phpnamespace Acme\Bundle\DemoEntityConfigBundle\Entity;use Doctrine\ORM\Mapping as ORM;use Oro\Bundle\EntityConfigBundle\Metadata\Annotation\Config;/*** @ORM\Entity* @ORM\Table(name="acme_hotel")* @Config(* defaultValues={* "entity"={* "icon"="fa-home",* "label"="Hotel",* "entity_label" ="XHotel"* }* })*/class Hotel{// ...}After that I run CLI-command:
$ ./bin/console oro:entity-config:update1.
Good news: Entity shows up on Backend >System > Entities > Entity Manger2. Bad News: Column-label is not shown (translated) correctly:
acme.demoentityconfig.hotel.entity_label insted of ‘Hotel’, or ‘XHotels’Debugging with:
$ ./bin/console oro:entity-config:debug “Acme\Bundle\DemoEntityConfigBundle\Entity\Hotel”results in console-output:
PHP123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687Class: Acme\Bundle\DemoEntityConfigBundle\Entity\HotelMode: defaultValues:Array([security] => Array([field_acl_supported] => false[field_acl_enabled] => false[show_restricted_fields] => false)[attachment] => Array([enabled] => false[maxsize] => 1[auto_link_attachments] => false)[entity] => Array([label] => acme.demoentityconfig.hotel.entity_label[plural_label] => acme.demoentityconfig.hotel.entity_plural_label[description] => acme.demoentityconfig.hotel.entity_description[icon] => fa-home[entity_label] => XHotels)[attribute] => Array([has_attributes] => false)[extend] => Array([owner] => System[is_extend] => false[state] => Active[is_deleted] => false[upgradeable] => true[origin] => System[pk_columns] => Array([0] => id))[acme] => Array([comment] => acme.demoentityconfig.hotel.entity_acme_comment)[activity] => Array([show_on_page] => \Oro\Bundle\ActivityBundle\EntityConfig\ActivityScope::VIEW_PAGE)[dataaudit] => Array([auditable] => false)[tag] => Array([enabled] => false[enableGridColumn] => true[enableGridFilter] => true[enableDefaultRendering] => true)[workflow] => Array([show_step_in_grid] => true)[comment] => Array([enabled] => false)[acme_hotel] => Array([comment] => acme.demoentityconfig.hotel.entity_acme_hotel_comment))Questions:
—
I. Should I ‘translate’ label instead trying to set it with @config() ? How a translation could look like (path/filename + sample configuration – thanks a lot!)?II. “entity_label” is not the right parameter for column-label configuration in data-grid, obviously. However I failed in deleting/overwriting it! How I can remove a parameter, set previously?
PHP123456789101112131415161718192021222324<?phpnamespace Acme\Bundle\DemoEntityConfigBundle\Entity;use Doctrine\ORM\Mapping as ORM;use Oro\Bundle\EntityConfigBundle\Metadata\Annotation\Config;/*** @ORM\Entity* @ORM\Table(name="acme_hotel")* @Config(* defaultValues={* "entity"={* "icon"="fa-home",* "label"="AcmeHotel"* }* })*/class Hotel{// ...}Of course, I deleted the cache:
PHP12345$ ./bin/console oro:entity-config:cache:clear --no-warmup$ ./bin/console cache:clear --env=prod$ ./bin/console cache:clear$ ./bin/console oro:entity-config:update$ ./bin/console oro:entity-config:debug "Acme\Bundle\DemoEntityConfigBundle\Entity\Hotel"Config Debug results always in the same:
PHP12345678[entity] => Array([label] => acme.demoentityconfig.hotel.entity_label[plural_label] => acme.demoentityconfig.hotel.entity_plural_label[description] => acme.demoentityconfig.hotel.entity_description[icon] => fa-home[entity_label] => XHotels)But I would expect:
PHP1234567[entity] => Array([label] => acme.demoentityconfig.hotel.entity_label[plural_label] => acme.demoentityconfig.hotel.entity_plural_label[description] => acme.demoentityconfig.hotel.entity_description[icon] => fa-home)June 5, 2019 at 7:38 am #39027Hi Ilya,
found a/(the?) solution, and it is really crazy:
I have to delete entity-attributes first, and update config then:
[B] stands for: “Acme\Bundle\DemoEntityConfigBundle\Entity\Hotel”
PHP123$ ./bin/console oro:entity-config:debug [B] --scope=entity --attr=entity_label --remove$ ./bin/console oro:entity-config:debug [B] --scope=entity --attr=label --remove$ ./bin/console oro:entity-config:debug [B] --scope=entity --attr=plural_label --removeAfter them only, framework is free to accept:
PHP12345678910111213141516171819202122232425<?phpnamespace Acme\Bundle\DemoEntityConfigBundle\Entity;use Doctrine\ORM\Mapping as ORM;use Oro\Bundle\EntityConfigBundle\Metadata\Annotation\Config;/*** @ORM\Entity* @ORM\Table(name="acme_hotel")* @Config(* defaultValues={* "entity"={* "label"="AcmeHotel",* "plural_label"="AcmeHotels",* "icon"="fa-home"* }* })*/class Hotel{// ..}when I am running:
$ ./bin/console oro:entity-config:updateNow :)
$ ./bin/console oro:entity-config:debug “Acme\Bundle\DemoEntityConfigBundle\Entity\Hotel”outputs to the screen
PHP1234567[entity] => Array([label] => AcmeHotel[plural_label] => AcmeHotels[description] => acme.demoentityconfig.hotel.entity_description[icon] => fa-home)And in Backend > System > Entities > Entity-Management
The correct column-‘label’ is displayed in data-grid-table.—
BUT :-(
in single entity-view: Backend > System > Entities > Entity-Manager > Click on AcmeHotel-label > Open ‘Entity / AcmeHotel’-page
Label – is not available
Plural-Label – is not availableIt seems, some translation is still needed, but where (whith use of which yml-file), and how to setup nodes / keys /values there?
I did not found any documentation, which would be helpful for that!
Thank you.
KR
FrankJune 5, 2019 at 8:01 am #39028It becomes MORE CRAZY:
In single entity-view: Backend > System > Entities > Entity-Manager > Click on AcmeHotel-label > Open ‘Entity / AcmeHotel’-page > Update
I can assign a new ‘label’ > AHX, ‘plural-label’ > AHXs , ‘description’ > Wellness and Sea …
After saving those values, they are stored somewhere, and opening the entity-page in entity-manager again, those values are displayed again …
HOWEVER, debugging with:
$ ./bin/console oro:entity-config:debug “Acme\Bundle\DemoEntityConfigBundle\Entity\Hotel”shows my old values:
PHP1234567[entity] => Array([description] => acme.demoentityconfig.hotel.entity_description[label] => AcmeHotel[plural_label] => AcmeHotels[icon] => fa-home)2 independent ways (Backend Entity-Manager /defining @config() in Entity-PHP-Class) to update the same attributes, but stored in different places in the DB????? Can’t believe this!
Thanks for explanation.
FrankJune 5, 2019 at 10:54 am #39032I ‘ve got it, finally (file names, path … are from my demo example):
—
1. Create PHP-Class to define entity, setting @config() in PHP-Doc.
Set attributes only, which are not defined by default:
I have set one attribute “icon”=”fa-home”, which is not default, and
I have NOT set “label”, “plural_label”, and “description”, which are defined by defaultSee use case:
https://github.com/oroinc/OroCRMTaskBundle/blob/48622b405dce7c7288b8fb17afe1fb0bd249dc16/Entity/Task.phpPHP123456789101112131415161718192021222324252627282930313233343536373839404142434445464748<?phpnamespace Acme\Bundle\DemoEntityConfigBundle\Entity;use Doctrine\ORM\Mapping as ORM;use Oro\Bundle\EntityConfigBundle\Metadata\Annotation\Config;/*** @ORM\Entity* @ORM\Table(name="acme_hotel")* @Config(* defaultValues={* "entity"={* "icon"="fa-home"* }* })*/class Hotel{/*** @ORM\Id* @ORM\Column(type="integer")* @ORM\GeneratedValue(strategy="AUTO")*/private $id;/*** @ORM\Column(type="string", length=255)*/private $name;public function getId(){return $this->id;}public function getName(){return $this->name;}public function setName($name){$this->name = $name;}}2. Create Migration (some PHP-class to updaten DB-schema):
To do this half-automated, I have dumped migration schema by using console-command:PHP1$ ./bin/console oro:migration:dump --bundle AcmeDemoEntityConfigBundle… copied the output,and pasted it to PHP-migration-class:
src/Acme/Bundle/DemoEntityConfigBundleMigrations/Schema/v1_0/Hotel.phpPHP1234567891011121314151617181920212223<?phpnamespace Acme\Bundle\DemoEntityConfigBundle\Migrations\Schema\v1_0;use Doctrine\DBAL\Schema\Schema;use Oro\Bundle\MigrationBundle\Migration\Migration;use Oro\Bundle\MigrationBundle\Migration\QueryBag;class Hotel implements Migration{//public function up(Schema $schema, QueryBag $queries){//$schema->dropTable('acme_hotel');$table = $schema->createTable('acme_hotel');$table->addColumn('id', 'integer', ['autoincrement' => true]);$table->addColumn('name', 'string', ['length' => 255]);$table->setPrimaryKey(['id']);$table->addIndex(['name'], 'hotel_name_idx', []);}}3. Load migration:
PHP1$ .bin/console oro:migration:load --force4. Translate Entity-Labels:
create: scr/Acme/Bundle/DemoEntityConfigBundle/Resources/translations/messages.en.ymlSee OroDoc: > Standard Symfony Translator
https://oroinc.com/oroplatform/doc/current/dev-guide/translationsPHP12345678910acme:demoentityconfig:hotel:entity_label: THotelentity_plural_label: THotelsentity_description: "Hotels for trainings"name:label: Nameid:label: ID5. Run Entity-config update
PHP1$ php bin/console oro:entity-config:updateCache-clearing may be helpful:
PHP1$ bin/console oro:entity-config:cache:clear --no-warmup6. Check results:
a) Output current entity-config (translations are not shown, of course):PHP1bin/console oro:entity-config:debug "Acme\Bundle\DemoEntityConfigBundle\Entity\Hotel"Output helps to address correct attributes for entity-definition (@config step 1), and identifying correct attribute keys for translations (step 4).
PHP123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596Class: Acme\Bundle\DemoEntityConfigBundle\Entity\HotelMode: defaultValues:Array([security] => Array([field_acl_supported] => false[field_acl_enabled] => false[show_restricted_fields] => false)[attachment] => Array([enabled] => 0[maxsize] => 1[auto_link_attachments] => NULL[mimetypes] =>)[entity] => Array([icon] => fa-home[label] => acme.demoentityconfig.hotel.entity_label[plural_label] => acme.demoentityconfig.hotel.entity_plural_label[description] => acme.demoentityconfig.hotel.entity_description)[attribute] => Array([has_attributes] => false)[extend] => Array([owner] => System[is_extend] => false[state] => Active[is_deleted] => false[upgradeable] => true[origin] => System[pk_columns] => Array([0] => id))[acme] => Array([comment] => acme.demoentityconfig.hotel.entity_acme_comment)[activity] => Array([show_on_page] => \Oro\Bundle\ActivityBundle\EntityConfig\ActivityScope::VIEW_PAGE[activities] => Array())[dataaudit] => Array([auditable] => 0)[tag] => Array([enabled] => 0[enableGridColumn] => true[enableGridFilter] => true[enableDefaultRendering] => true)[workflow] => Array([show_step_in_grid] => 1)[comment] => Array([enabled] => 0)[acme_hotel] => Array([comment] => acme.demoentityconfig.hotel.entity_acme_hotel_comment)[search] => Array([searchable] => 0))b) Last not least, check entity-availabilty and correct label-translations in admin-UI via:
backend > System > Entities > Entity Manger
backend > System > Entities > Entity Manager > click on/open ‘THotel’- entityFrom backend admin can update Hotel-entity. This will overwrite translations in messages.en.yml.
Once you want to remove those UI-defined entity-attributes, you have to remove them from the console via command (for example remove the UI-defined ‘description’), [Bundle] is the placeholder for “Acme\Bundle\DemoEntityConfigBundle\Entity\Hotel”:PHP1./bin/console oro:entity-config:debug [Bundle] --scope=entity --attr=description --removeThat’s it. May be it’s helpful for someone. Thank Ilja for help!
FrankJune 6, 2019 at 1:33 am #39041Glad to see that you’ve resolved you issue.
JFI configuration in php class is “default”. And this default information is loading to the DB during oro:entity-config:update or install process.
If you just remove this configuration form php file it still will be in DB.
- AuthorReplies
The forum ‘OroCRM’ is closed to new topics and replies.