Forums › Forums › OroCRM › OroCRM – Feature Requests › Send email to Case assignee when assignee is changed
This topic contains 26 replies, has 4 voices, and was last updated by Bhavesh Tailor 7 years, 1 month ago.
Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.
- CreatorTopic
- January 6, 2017 at 10:16 am #29991
When a Case is assigned, or when the assignee is changed, I want the new assignee to be notified by email.
So I go to System > Emails > Notification Rules and I start adding a new rule. I choose “Case” as the Entity Name, but it seems the only “dynamic” recipient I can choose is the Case owner — I can’t choose the Case assignee. Furthermore, the only Event Name options I have are “Entity create”, “remove”, and “update” — “Entity change assignee” is not an event option.
Questions:
1) Have I correctly understood the limitations of the Notification Rules system, or is there some way to get it to do what I want?2) If it cannot do what I want, are there any plans to make it more flexible?
3) In the meantime, can I add some custom code to do what I need? How would I begin? Can I add an event listener that can identify if the assignee has been changed?
- CreatorTopic
- AuthorReplies
- January 10, 2017 at 8:30 am #29992
Hi
You should use processes, for example:
PHP1234567891011121314151617181920212223242526272829definitions:send_case_mail:label: 'Case Email'enabled: trueentity: OroCRM\Bundle\CaseBundle\Entity\CaseEntityorder: 1actions_configuration:- '@tree':actions:- '@send_email_template':attribute: $.emailfrom: 'from@gmail.com'to: $.assignedTo.emailtemplate: 'case_template'entity: $.datatriggers:send_case_mail:-event: createfield: assignedToqueued: truetime_shift: 1-event: updatefield: assignedToqueued: truetime_shift: 1Don’t forget run:
Shell1app/console oro:process:configuration:loadJanuary 10, 2017 at 9:21 am #29993Mike,
That seems like a great solution. Thanks for your help. I’ll post back once I have a chance to try it out.
January 12, 2017 at 12:02 am #29994Hi Mike ,
I want to create case from embedded web form . If User Exist into our system then it should be save as case other wise it’s save into contact request listing . is this process possible . i did try to create process.yml but i am not able to store value .
PHP123456789101112131415161718192021222324definitions:create_case:label: 'Create Case form Embedded Web Form'enabled: trueentity: OroCRM\Bundle\ContactUsBundle\Entity\ContactRequestorder: 10actions_configuration:- @tree: # set Contactconditions: # if Contact not exists@empty: $contactactions:- @create_entity: # create Contactclass: OroCRM\Bundle\ContactBundle\Entity\CaseEntityattribute: $contactEntityInstancedata:relatedContact: $contactowner: $ownerorganization: $organizationtriggers:create_case:-event: createpriority: 5queued: trueand after this code run app/console oro:process:configuration:load.
Bhavesh
January 12, 2017 at 8:11 am #29995Hi
I have created example based on your requirements, but i used Contact instead ContactRequest:
YAML1234567891011121314151617181920212223242526272829303132333435363738394041definitions:create_case:label: 'Create Case form Embedded Web Form'enabled: trueentity: OroCRM\Bundle\ContactBundle\Entity\Contactorder: 10actions_configuration:- @tree:conditions:@empty: $lastNameactions:- '@find_entity':attribute: $.caseSourceclass: OroCRMCaseBundle:CaseSourceidentifier: 'email'- '@find_entity':attribute: $.caseStatusclass: OroCRMCaseBundle:CaseStatusidentifier: 'open'- '@find_entity':attribute: $.casePriorityclass: OroCRMCaseBundle:CasePriorityidentifier: 'normal'- @create_entity:class: OroCRM\Bundle\CaseBundle\Entity\CaseEntityattribute: $.contactEntityInstancedata:relatedContact: $.dataorganization: $organizationowner: $ownersubject: $firstNamesource: $.caseSourcestatus: $.caseStatuspriority: $.casePrioritytriggers:create_case:-event: createpriority: 5queued: trueI show why your process can not work.
YAML1@empty: $contactcondition check, $contact is empty or not, i think your $contact is not empty because your actions doesn’t executed
YAML1class: OroCRM\Bundle\ContactBundle\Entity\CaseEntityThis is wrong path to CaseEntity. Please change it to CaseBundle.
YAML1attribute: $contactEntityInstanceIn this case you are trying set new Case Entity to contactEntityInstance property of Contact Entity. Try to change it to $.contactEntityInstance (case entity will be saved to temporary contactEntityInstance attribute)
Also you should set subject, status, priority and source.
If your process is triggering as ‘queued: true’ cron daemon must be run. Please add it to crontab.Shell1app/console oro:cronWhen your entity will be created (in your case it ContactRequest) every time you can see new job on this url /cron/job
January 16, 2017 at 1:20 am #29996Hi Mike,
form this code also i am not able to create case using embedded form . I have crated process.yml under Resources/config/process.yml .
Is this location is correct or need to create into Resource/config/oro . ?after that i have run app/console oro:process:configuration:load.
I am not sure what should i add into cron tab, you means to say need to add ‘queued: true’ into cron tab
please suggest me .
Thank You
Bhavesh
January 16, 2017 at 6:31 am #29997Hi
If you have earlier than 2.0 version of orocrm Resources/config/process.yml is correct path for your file, otherwise put it in Resources/config/oro/processes.yml. You should add to crontab this command, in this case your process (create_case) can working on regular basis (for example: when ContactRequest has created, @create_entity action go to queue and when command has been executed it gets all queued actions and create entities on real database)
Shell1[path to your crm]/app/console oro:cronJanuary 17, 2017 at 5:48 am #29998Hi Mike ,
Thank You for your quick response . Still i am confuse i am not able to create case if user exist . i have save this process.yml into /orocrmdemo/src/XYZ/Bundle/ContactUsBundle/Resources/config/process.yml . i need to create this file into this bundle or embedded bundle .
as per your instruction i have added code into crontab -e
*/1 * * * * /usr/bin/php /home/ilogix/Workspace/orocrmdemo/app/console –env=prod oro:cron >> /dev/nullBut not get result .
Bhavesh
January 18, 2017 at 5:42 am #29999Hi
1. Let’s ensure that your ‘process’ is loaded, does message appear, when you run this command ? If no, your bundle not working.
process definition: “create_case” – created
Shell1app/console oro:process:configuration:load2. Can you show me your process.yml ? Do you change it ?
Still i am confuse i am not able to create case if user exist
3. Are we talking about entity UserBundle/Entity/User.php or ContactBundle/Entity/Contact.php? Can you tell me what is ‘user’ and where it located ?
January 19, 2017 at 2:15 am #30000Hi Mike ,
1. While executing command getting this message
PHP12app/console oro:process:configuration:load[info] > process definition: "create_case" - updated2: I am trying to store Process file inside
/Workspace/orocrmdemo/src/MarketSnap/Bundle/ContactUsBundle/Resources/config/process.yml
define path is correct or need to create into
/home/ilogix/Workspace/orocrmdemo/src/MarketSnap/Bundle/EmbeddedFormBundle/Resources/config/process.yml
My process.yml
PHP1234567891011121314151617181920212223242526272829303132333435363738394041definitions:create_case:label: 'Create Case form Embedded Web Form'enabled: trueentity: OroCRM\Bundle\ContactBundle\Entity\ContactRequestorder: 10actions_configuration:- @tree:conditions:@empty: $lastNameactions:- '@find_entity':attribute: $.caseSourceclass: OroCRMCaseBundle:CaseSourceidentifier: 'email'- '@find_entity':attribute: $.caseStatusclass: OroCRMCaseBundle:CaseStatusidentifier: 'open'- '@find_entity':attribute: $.casePriorityclass: OroCRMCaseBundle:CasePriorityidentifier: 'normal'- @create_entity:class: OroCRM\Bundle\CaseBundle\Entity\CaseEntityattribute: $.contactEntityInstancedata:relatedContact: $.dataorganization: $organizationowner: $ownersubject: $firstNamesource: $.caseSourcestatus: $.caseStatuspriority: $.casePrioritytriggers:create_case:-event: createpriority: 5queued: trueand as per you instruction i have added code into crontab also
*/1 * * * * /usr/bin/php /home/ilogix/Workspace/orocrmdemo/app/console –env=prod oro:cron >> /dev/null
3: I want to create case from contact request, if user exist into contact list then case should me created other wise data will be save as contact request .
Bhavesh
January 23, 2017 at 5:34 am #30001Hi Mike ,
I have created using custom code . but not able to create using process.yml . Please suggest how can i implement because custom code take too much time to save data .
Thank You
Bhavesh
January 23, 2017 at 7:15 am #30002Hello Mike ,
I did remove b2b customer field from opportunity thats why into my table orocrm_sales_opportunity customer_id is null. While i trying to edit status,probability etc. then i got error “This value should not be blank.” . While i remove code from
OroCRM/Bundle/SalesBundle/Resources/config/validation.yml
customer:
– Valid: ~
– NotBlank: ~Then I am able to update fields . How can i override this validation.yml for inline edit datagrid
Is there any way to override OroCRM/Bundle/SalesBundle/Resources/config/validation.yml form our custom bundle . i did try validation_groups into custom folder
/Workspace/orocrmdemo/src/MarketSnap/Bundle/SalesBundle/Form/Type/OpportunityType.php
or also try
/home/ilogix/Workspace/orocrmdemo/src/MarketSnap/Bundle/SalesBundle/Form/Extension/OpportunityTypeExtension.phplike
PHP12345678910public function setDefaultOptions(OptionsResolverInterface $resolver){$resolver->setDefaults(array(‘data_class’ => ‘OroCRM\Bundle\SalesBundle\Entity\Opportunity’,‘intention’ => ‘opportunity’,‘validation_groups’ => [‘ms_edit’]));}it’s not work for opportunity datagrid inline edit . Please suggest me how can i solve this issue .
As Per mention into above post while i remove customer constraint from validation.yml and clear the cache it’s work for me but with this constraint i am not able to edit datagrid data .Thank You
Bhavesh
January 25, 2017 at 6:02 am #300032: I am trying to store Process file inside
/Workspace/orocrmdemo/src/MarketSnap/Bundle/ContactUsBundle/Resources/config/process.ymldefine path is correct or need to create into
/home/ilogix/Workspace/orocrmdemo/src/MarketSnap/Bundle/EmbeddedFormBundle/Resources/config/process.ymlIt doesn’t matter how you named your bundle, ContactUsBundle or EmbeddedFormBundle. The most important enable it in src/Custom/Bundle/YourBundle/Resources/config/oro/bundles.yml
3: I want to create case from contact request, if user exist into contact list then case should me created other wise data will be save as contact request .
As i understood you have the following flow:
In contact request form email field is mandatory.
1. I think you should search contact by email. Something like this “select * from orocrm_contact c where c.email = ’email which user entered'”.
1.1 Contact has been found – case must be created, ContactRequest is not.
1.2 Contact hasn’t been found – ContactRequest must be created, case is not.
Right ?
January 25, 2017 at 10:10 am #30004Is there any way to override OroCRM/Bundle/SalesBundle/Resources/config/validation.yml form our custom bundle
Yes, set to your custom validation.yml the following yml:
YAML123456789101112131415161718192021222324252627282930313233OroCRM\Bundle\SalesBundle\Entity\Opportunity:properties:name:- NotBlank:groups: [CustomValidation]- Length:max: 255groups: [CustomValidation]probability:- Range:min: 0max: 100groups: [CustomValidation]budgetAmount:- Range:min: 0groups: [CustomValidation]closeRevenue:- Range:min: 0groups: [CustomValidation]customer:- Blank:groups: [CustomValidation]dataChannel:- NotBlank:groups: [CustomValidation]organization:- NotBlank:groups: [CustomValidation]status:- NotBlank:groups: [CustomValidation]Further you can override OpportunityType.php – remove ‘customer’ field and set ‘validation_groups’ to ‘CustomValidation’. I think you can do this also in OpportunityTypeExtension.php
At the moment you can’t change ‘validation_groups’ in inline edition. I suggest you override getForm function with the following code:
PHP123456789101112131415161718192021public function getForm($entity){$options = ['csrf_protection' => false,'dynamic_fields_disabled' => true];if ($entity instanceof Opportunity) {$options['validation_groups'] = ['CustomValidation'];}$form = $this->formFactory->createBuilder('form',$entity,$options)->getForm();return $form;}January 25, 2017 at 11:38 am #30005Hello Mike,
I work with ianfp and I created the process.yml and added the process you suggested. I also was able to create the process and it now appears on the process list under System > Processes
However, the email is not being sent when I change the assignee in a sample case. From the sample process.yml you provided I changed the template to one I created and changed the from to a valid email address.
Could you please let me know what I am doing wrong?
Thanks,
CelineJanuary 25, 2017 at 10:45 pm #30006Hi Mike ,
It’s work for me .
Thank You
Bhavesh
- AuthorReplies
The forum ‘OroCRM – Feature Requests’ is closed to new topics and replies.