ssossossosso

Forums

Covering OroCRM topics, including community updates and company announcements.  Subscribe

This topic contains 4 replies, has 2 voices, and was last updated by  shreyas 1 year, 1 month ago.

  • Creator
    Topic
  • #22785

    shreyas
    Participant

    Hi Team ,

    We have a requirement wherein i need to send email to Customers(Leads) once a appointment to a context(Customer) is set by creating a calendar event.This is a similar requirement that was done for automatic email triggering when a lead is created which was handled using Processes (link for reference : Automatic mail trigger when Lead Created using process.yml.

    Here i tried to go with processes but i am not knowing how to access the context’s email as only context’s name would be displayed in Calendar Event form. I also tried looking at Database structure for this wherein Context/lead mapping for this calendar events are done separately in a relation table which is linked with calendar event Id.Please find the Database structure screenshots for Calendar Event & relation table(oro_rel_46a29d1988a3cef5d4431f) given below:

    Calendar Event DB structure

    Calendar Evnt _ Lead Mapper

    I also tried going through the calendar Event form type wherein Its using a field called childEvents to display the contexts.
    Please find the form type of Calendar Event given below: (Proj_Dir\vendor\oro\platform\src\Oro\Bundle\CalendarBundle\Form\Type\CalendarEventType.php)

    Please need help in knowing how to go about with this, to trigger automatic mail to Customers(i.e Lead/Context & also if possible to Guests selected) who are related to the Calendar Event once a Calendar Event is created.

    Thanks & Regards,
    Shreyas S

Viewing 4 replies - 1 through 4 (of 4 total)
  • Author
    Replies
  • #22806

    shreyas
    Participant

    Hi Team ,

    I was able to access Guests selected during Calendar Event Appointment Creation in Process.yml to send them auto mails once appointment is set to them using $calendar.owner.email . But the issue faced here is even if i am able to send mails to Guests who are set for that appointment, the process jobs are failing as shown below:
    Error in Process Jobs

    But when i donot select any guest & process job , i get a successfully finished Status & mail triggers to the one who has set the appointment (i.e User Logged In). i Dont know how to go about to solve with this issue. i guess there is a different way in accessing the emails through process.yml since there would be multiple mails to be sent for a calendar event created.
    Please find below the Process.yml code:

    In the above code i am able to access Guests using $calendar.owner.email

    In the Calendar_reminder template i have used in process.yml above , i am unable to get proper link processed when a mail is received that is More Details link used to accept/Reject/tentatively attend meeting. Please find the screenshot given below:

    Calendar Template Issue

    Please find the source code slightly modified from existing Calendar_reminder template since process Job failed with existing Calendar_reminder template due to <style> issue for Entity :Calendar.

    Please need help in knowing how to resolve the above issues occured & Also in getting access to Contexts selected during Calendar Event Creation to send them automatic mails once an appointment is set.

    Thanks & Regards,
    Shreyas S

    #22866

    shreyas
    Participant

    Hi Team,

    I was able to get Lead Id to get lead emails with the help of Curl using the Hardcoded Url set in code which is not best way to get this working. So i am trying to get lead/Account Id based on API name instead of Url since the Url can change but not API Name given by OroCRM.

    Please find the Code Below wherein i have written a php class under Location:
    Proj_Dir\src\Custom\Bundle\CalendarBundle\Service\GetContext.php

    Here in above code i am able to get data through CURL with the help Url with the API defined i.e:
    http://shreyas.demosite.com/api/rest/latest/activities/calendarevents/$calendarId/context.json?_format=json
    Where in CalendarId is passed through Process.yml. Here i don’t want to use Curl & the URL of API to get Data instead need to Call the API through its name which is working fine when i tested it in an controller function . Please find the code given below for tested Data obtained from API (Loc: Proj_Dir\src\Custom\Bundle\CalendarBundle\Controller\CalendarEventController.php):

    With this Code Snippet above i am able to fetch data . i.e .. LeadId / Account Id through the Call to this function.But if the same function if i have used in GetContext.php file , then in Process.yml i am unable to get the leads & process job fails.

    Please find the partially working Process.yml that is able to fetch Lead Id from GetContext.php (implemented using Curl shown above) & get Lead/Account emails & send mail to them.

    Here in above Process.yml i am calling getLeadAccount from GetContext.php to get Lead Id/Account Id & passing it to respective entities to fetch their mail Id & sending it to send_email_template.

    Now using the Above Codes for Process.yml & GetContext.php i am able to get lead’s emails & process to send auto emails once appointment is created. But i would slightly need to change the GetContext.php file to not use Curl & API URL instead use the code i have tested in CalendarEventController shown above (i.e function getLeadAccount which contains logic written which used API Name to retrieve data)

    Please find the Code for GetContext.php i am trying now to eliminate the use of Curl Logic shown above:

    Here i am trying to use the API ‘oro_activity.manager.activity_context.api’ to get result. I have used $GLOBALS[‘kernel’] since i would not have access to get() method to call.This Code is working fine when i am trying to write service to this Code & call it in a Controller as shown below:

    Please find the Service for GetContext.php Called in Controller which is working fine to get the result id shown below:

    Now with these Code Changes when i try to use in process.yml , it does not work & process Job fails.

    I also tried different ways to get it working in Process.yml but i am stuck on how to solve this issue.
    Some of things tried were implementing ContainerAwareInterface in GetContext Class & adding a setContainer Method which would initialize container which would be used further in code. This setContainer would be called through service once this class object is created.

    Please find the code for GetContext.php file given below:

    In Services.yml changed the previous configuration of service custom_association.service.getcontext to given below:

    This is working again when called from controller but is not working in Process.yml i.e in process job shows failed status with no further errors nor any log.

    Please need help on how to go about with this issue.
    Thanks & Regards,
    Shreyas S

    #22948
    Mike Kudelya
    Mike Kudelya
    Oro Core

    Hi,

    I modified a bit your code. My process sends emails to account and lead.

    services.yml:

    CalendarContext.php:

    process.yml:

    #22954

    shreyas
    Participant

    Thanks a lot Mike for the solution.It Worked as expected!!!

    Thanks & Regards,
    Shreyas S

Viewing 4 replies - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.