Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.
Forum Replies Created
-
AuthorReplies
-
May 7, 2019 at 7:49 am in reply to: How to Translate Column Headers & Customize Columns(hide) for Datagrid Export #38796
Hi Andrey,
Thanks a lot for sharing this information.
Thanks & Regards,
Shreyas SMay 2, 2019 at 11:38 am in reply to: How to Translate Column Headers & Customize Columns(hide) for Datagrid Export #38757Hi Andrey,
Thanks a lot for such a quick response.
I checked at the link you shared it is working as expected.Is there any way where in the column headers will get translated based on how datagrid columns displayed in UI because as observed translation of headers is missing in export file.Thanks & Regards,
Shreyas SApril 22, 2019 at 10:03 am in reply to: How to get Entity Permission Information Based on Role Provided #38668Thanks Andrey for the guidance.
Thanks & Regards,
Shreyas SApril 22, 2019 at 10:01 am in reply to: How to Use processes/Message Queues to trigger Process in Background Immediately #38667Thanks a lot Andrey for quick response.
I will look at the guidance suggested by you.Thanks & Regards,
Shreyas SHi Yurii Muratov,
Thanks a lot for your quick reply. Sorry for delayed response .I had few doubts which i would like to clear from it.
My concern in this Date filter issue is that irrespective of the timezone we have selected , at last it gets saved in UTC format & retrieves in whatever timezone we have selected. So, for example i created some opportunities in Application which contains Expected close Date.Thus once i created an opportunity in Application & checked for Dates in DB . The Dates saved in DB & that created in Application the same.
Please find the observation below ( i have chosen for EN locale now):
List of all opportunities below:Now i use Date filter Between option for Expected close time filtering from Oct 19, 2017 till Oct 21, 2017 to be as follows:
Now if you notice the above filtered results , it does not contain result related to Oct 21,2017 . which i feel should have been listed in these filtered results. Please let me know if i am wrong about it.
Please find the DB related information for these data:
Locale Information is as follows:
Also logs just for reference:
Shell123[2017-11-03 16:33:39] doctrine.DEBUG: SELECT count(o0_.id) AS sclr_0 FROM orocrm_sales_opportunity o0_ WHERE (o0_.close_date >= ? AND o0_.close_date <= ?) AND o0_.status_id NOT IN (?) AND o0_.organization_id = 1 ["2017-10-19 00:00:00","2017-10-21 00:00:00",["lost","won"]] [][2017-11-03 16:33:39] event.DEBUG: Notified event "oro_datagrid.orm_datasource.result.before" to listener "Oro\Bundle\DataGridBundle\EventListener\OrmDatasourceAclListener::onResultBefore". [] [][2017-11-03 16:33:39] doctrine.DEBUG: SELECT o0_.id AS id_0, o0_.name AS name_1, o0_.created_at AS created_at_2, o0_.updated_at AS updated_at_3, o0_.close_date AS close_date_4, o0_.probability AS probability_5, o0_.budget_amount_value AS budget_amount_value_6, o0_.close_revenue_value AS close_revenue_value_7, o0_.budget_amount_currency AS budget_amount_currency_8, o0_.close_revenue_currency AS close_revenue_currency_9, o0_.status_id AS sclr_10, CONCAT_WS(' ', o1_.first_name, o1_.last_name) AS sclr_11, o1_.id AS id_12, o2_.label AS label_13, o3_.email AS email_14, o4_.id AS id_15, CONCAT_WS(' ', o4_.first_name, o4_.last_name) AS sclr_16, o5_.name AS name_17, o0_.ac_contact_count AS ac_contact_count_18, o0_.ac_contact_count_in AS ac_contact_count_in_19, o0_.ac_contact_count_out AS ac_contact_count_out_20, o0_.ac_last_contact_date AS ac_last_contact_date_21, o0_.ac_last_contact_date_in AS ac_last_contact_date_in_22, o0_.ac_last_contact_date_out AS ac_last_contact_date_out_23, DATEDIFF(CURRENT_DATE, o0_.ac_last_contact_date) AS sclr_24, o0_.organization_id AS sclr_25, o0_.user_owner_id AS sclr_26 FROM orocrm_sales_opportunity o0_ LEFT JOIN orocrm_contact o1_ ON o0_.contact_id = o1_.id AND (o1_.organization_id = 1) LEFT JOIN orocrm_sales_opport_close_rsn o2_ ON o0_.close_reason_name = o2_.name LEFT JOIN orocrm_contact_email o3_ ON o1_.id = o3_.owner_id AND (o3_.is_primary = 1) LEFT JOIN oro_user o4_ ON o0_.user_owner_id = o4_.id LEFT JOIN orocrm_sales_customer o6_ ON o0_.customer_association_id = o6_.id LEFT JOIN orocrm_account o5_ ON o6_.account_id = o5_.id AND (o5_.organization_id = 1) WHERE (o0_.close_date >= ? AND o0_.close_date <= ?) AND o0_.status_id NOT IN (?) AND o0_.organization_id = 1 ORDER BY o0_.created_at DESC, o0_.id DESC LIMIT 25 OFFSET 0 ["2017-10-18 18:30:00","2017-10-20 18:30:00",["lost","won"]] []This is similar issue which we faced with French locale being selected also (explained in above post). Please let me know if this is an issue or not. other doubt was that when the field used for filtering is of Date type why is it Date Time being taken into consideration here.
Thanks & Regards,
Shreyas SJune 6, 2017 at 4:39 am in reply to: Entity Access Restriction Not working to Users in Global Search in navigation #29313Hi Team,
i was able to restrict the Entity access with some modifications in Code as shown below:
In vendor\oro\platform\src\Oro\Bundle\SearchBundle\Provider\ResultStatisticsProvider.php
PHP123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135<?phpnamespace Oro\Bundle\SearchBundle\Provider;use Symfony\Component\Translation\TranslatorInterface;use Oro\Bundle\EntityConfigBundle\Config\ConfigManager;use Oro\Bundle\EntityConfigBundle\Config\Id\EntityConfigId;use Oro\Bundle\SearchBundle\Engine\Indexer;use Oro\Bundle\SearchBundle\Query\Result\Item;use Oro\Bundle\SearchBundle\Security\SecurityProvider;class ResultStatisticsProvider{/*** @var Indexer*/protected $indexer;/*** @var ConfigManager*/protected $configManager;/*** @var TranslatorInterface*/protected $translator;/** @var SecurityProvider */protected $securityProvider;/*** @param Indexer $indexer* @param ConfigManager $configManager* @param TranslatorInterface $translator* @param SecurityProvider $securityProvider*/public function __construct(Indexer $indexer, ConfigManager $configManager, TranslatorInterface $translator,SecurityProvider $securityProvider){$this->indexer = $indexer;$this->configManager = $configManager;$this->translator = $translator;$this->securityProvider = $securityProvider;}/**** @param $query* @return \Oro\Bundle\SearchBundle\Query\Result*/public function getResults($query){return $this->indexer->simpleSearch($query);}/*** Returns grouped search results** @param string $string* @return array*/public function getGroupedResults($string){$search = $this->getResults($string);// empty key array contains all data$result = array('' => array('count' => 0,'class' => '','config' => array(),'icon' => '','label' => ''));/** @var $item Item */foreach ($search->getElements() as $item) {$config = $item->getEntityConfig();$entityClass = $item->getEntityName();$objectString = 'Entity:' . $entityClass;if ($this->securityProvider->isProtectedEntity($entityClass)&& !$this->securityProvider->isGranted('VIEW', $objectString)){//do nothing}else{$alias = $config['alias'];if (!isset($result[$alias])) {$group = array('count' => 0,'class' => $item->getEntityName(),'config' => $config,'icon' => '','label' => '');if (!empty($group['class']) && $this->configManager->hasConfig($group['class'])) {$entityConfigId = new EntityConfigId('entity', $group['class']);$entityConfig = $this->configManager->getConfig($entityConfigId);if ($entityConfig->has('plural_label')) {$group['label'] = $this->translator->trans($entityConfig->get('plural_label'));}if ($entityConfig->has('icon')) {$group['icon'] = $entityConfig->get('icon');}}$result[$alias] = $group;}$result[$alias]['count']++;$result['']['count']++;}}uasort($result,function ($first, $second) {if ($first['label'] == $second['label']) {return 0;}return $first['label'] > $second['label'] ? 1 : -1;});return $result;}}In function getGroupedResults() done some modification to check for Entity Access with help of securityProvider.
Also done respective changes in services.yml for oro_search.provider.result_statistics_provider as below:
YAML123456789oro_search.provider.result_statistics_provider:class: %oro_search.provider.result_statistics_provider.class%arguments:- @oro_search.index- @oro_entity_config.config_manager- @translator- @oro_search.security_providerlazy: trueNow the Custom entity Search result is not shown other than for ADMIN Role.
But i am facing similar issue related to Entity’s Record level Access, where in ACL might not be working properly.
Ex:
i have a User who has created an Account record. This account’s record should not be visible to other user other than created user as the ownership is also registered in ACL of Account Entity.But this is not working fine with Search Result wherein it is listing many records that are not applicable to him or Business Units
under him whereas on the Account Entity index page it displays only records applicable to that user. When i try clicking on some of those search result’s records it says no permission to view record.i observed that SearchAclHelper is being used in vendor\oro\platform\src\Oro\Bundle\SearchBundle\Engine\Indexer.php in prepareQuery() method but not working as expected.Please find code snippet for reference:
PHP12345678910/*** Do query manipulations such as ACL apply etc.** @param Query $query*/protected function prepareQuery(Query $query){$this->applyModesBehavior($query);$this->searchAclHelper->apply($query);}I tried commenting $this->searchAclHelper->apply($query); from above function. Then when i searched for particular search text under Account Entity from Different Users . Then number of records fetched were the same. So once after uncommenting it under each User the search result is varying but there are some Records which user does not have access to also being displayed.This is the same problem for other entities search result also.
Kindly need help in how to solve this Record Level Access Restriction of Entities to users.Hi Michael,
I guess we are using OroCRM 1.10.x Version. i tried looking at My_Application/platform/information for Oro Package details.Please find the given version details below :
How can i find which version of OroCRM are we using? Since as per platform/information both oro/platform & oro/crm version is shown as dev-master.Also, Is there any way that can be used for Workflow Translations for versions prior to 2.0.0.
Thanks & Regards,
Shreyas SThanks Hryhorii,
Its working fine now after deleting the js.
Thanks & Regards,
Shreyas SHi Hryhorii,
Thanks for the suggestion.i tried following the steps of deleting the oro.min.js file from web/js & using the command: app/console oro:requirejs:build . But this throws me runtime exception as given below:
123[RuntimeException]Error: TypeError: Cannot call method 'indexOf' of nullat Function.build.makeAbsPath (/websites/shreyas/crm-application/web/bundles/ororequirejs/lib/r.js:26494:18)Please find screenshot for the same:
So, when i go back to the web/js i cannot find the generated oro.min.js due to the exception that is occured. I tried placing back oro.min.js which was taken back up before removing in web/js. And then try executing this command but it gives same error.
Kindly need help in how to fix this issue.
Thanks & Regards,
Shreyas SHi Mike,
Thanks a lot for Suggestion. I tried removing part of code which had DB activities (i.e removed getRepository & also DB code present in getDefaultDefinition(). And kept only a single statement inside execute() function i.e: $output->writeln(“Execution Started”);. It gave the same error. There was some problem in my instance’s Database i think since when i used my instance code connect to different copy of Database with same tables & entities configuration by changing Database name in parameters.yml it worked perfectly fine without any issues.So i think my Database Tables had some issue now it is working fine after changing the Database.Thanks,
Shreyas SHi Team,
I am also facing the same issue when language is French. it works fine in previous OroCRM version but in the new version facing this issue. I guess the issue is in oro.min.js present in web/js.Because when i tried replacing this js file with previous version’s js file it worked for Dates & also gets saved to DB successfully(My_application_PATH/task/create) but gives some js errors when loading any other pages. I tried looking at changes from previous version of js with this new js but could not get much idea in how to resolve this Datepicker validation issue.Please need help in knowing what changes need to be done in new oro.min.js as i cannot use older version of js since many other functionalities would not work.
The problem faced here is most of Months in DatePicker would have special characters in it. Ex: D`ec . So OROCRM gives that error saying that not a valid date. For other months which does not involve any special characters it does not throw any errors & works fine.
Kindly need help in this problem.
Thanks & Regards,
Shreyas SHI Mike,
Thanks a lot for sharing the link . It worked. From the link both Solution 1 & Solution 4 were suitable for our Stored Procedure. i.e 1) using of closeCursor() (or) 2) using of unset() .Please find the working code snippet shared for the same:
PHP12345678910111213141516171819202122232425262728293031323334353637383940414243public function leadbysrcformonthAction(){$seldat1 = date('Y-m-01');$seldat2 = date('Y-m-d');$loggedinuserId = $this->get('security.context')->getToken()->getUser()->getId();$orgId = $this->get('oro_user.manager.api')->find($loggedinuserId)->getOwner()->getOrganization()->getId();$limitsel = 0;$offset = 0;$page = 0;$countperpage = 20;if ($_GET) {$page = $_GET['page'];}if ($page > 1) {$offset = $count_per_page * ($page - 1);}$qry = "call GetLeadsbySrcMonthWise('$seldat1','$seldat2',$orgId,0,0,'none')"; // if 0,0 means ALL RECORDS TO BE DISPLAYED$connection = $this->getDoctrine()->getManager()->getConnection();$getallleads = $connection->prepare($qry);$getallleads->execute();$noofrows = $getallleads->rowCount();//$getallleads->closeCursor();unset($getallleads);// Solution 1$qry2 = "call GetLeadsbySrcMonthWise('$seldat1','$seldat2',$orgId,$offset,$countperpage,'none')";$getleadsperpage = $connection->prepare($qry2);$getleadsperpage->execute();$getleadsperpageres = $getleadsperpage->fetchAll();$getleadsperpage->closeCursor(); // Solution 2if ($page == 0) {$thispage = 1;} else {$thispage = $page;}$tot_pages = ceil($noofrows / 20);$src = "select * FROM oro_enum_lead_source";$source = $connection->prepare($src);$source->execute();$source_res = $source->fetchAll();return $this->render('CustomSalesBundle:Lead:statusreportbymonth.html.twig',array('resultset' => $getleadsperpageres,'src' => $source_res,'numofrows' => $tot_pages,'thisPage' =>$thispage));}From the code above any of the two solutions(using unset / using closeCursor) can be used to deal with the exception occured.
Thanks a lot for the help again!Thanks & Regards,
Shreyas SSeptember 26, 2016 at 5:44 am in reply to: How to Send mail to Context whose appointment is set in calendar event #30458Thanks a lot Mike for the solution.It Worked as expected!!!
Thanks & Regards,
Shreyas SSeptember 16, 2016 at 9:09 am in reply to: How to Send mail to Context whose appointment is set in calendar event #30456Hi 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.phpPHP123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129<?phpnamespace Custom\Bundle\CalendarBundle\Service;use Symfony\Component\PropertyAccess\PropertyAccess;class GetContext{/*** @param int $calendarId* @param string $chkifleadoraccount* @return int*/public function getLeadAccount($calendarId,$chkifleadoraccount){$username = 'demo';$apiUserKey = '6c123d583ce1cc365b33b4da8b8685d5535c678a';//$uri = $_SERVER['HTTP_HOST'].'/';$url = "http://shreyas.demosite.com/api/rest/latest/activities/calendarevents/$calendarId/context.json?_format=json";$oroWsse = new Authentication($username, $apiUserKey);$headers = $oroWsse->getHeaders();$resArr = array();$options = array(CURLOPT_RETURNTRANSFER => true, // return web pageCURLOPT_HEADER => false, // don't return headersCURLOPT_HTTPHEADER => $headers,CURLOPT_FOLLOWLOCATION => true, // follow redirectsCURLOPT_MAXREDIRS => 10, // stop after 10 redirectsCURLOPT_ENCODING => "", // handle compressedCURLOPT_USERAGENT => "test", // name of clientCURLOPT_AUTOREFERER => true, // set referrer on redirectCURLOPT_CONNECTTIMEOUT => 120, // time-out on connectCURLOPT_TIMEOUT => 120, // time-out on response);$ch = curl_init($url);curl_setopt_array($ch, $options);$content = curl_exec($ch);curl_close($ch);$resArr = json_decode($content);$contextid = '';// $chkifleadoraccount;foreach($resArr as $re){if(($chkifleadoraccount == 'OroCRM_Bundle_AccountBundle_Entity_Account') && ($re->targetClassName == 'OroCRM_Bundle_AccountBundle_Entity_Account')){$contextid = $re->targetId; //Account id}else if(($chkifleadoraccount == 'OroCRM_Bundle_SalesBundle_Entity_Lead') && ($re->targetClassName == 'OroCRM_Bundle_SalesBundle_Entity_Lead')){$contextid = $re->targetId;}else{//exception}}return $contextid;}}class Authentication {protected $_username;protected $_apiKey;/*** @param $username* @param $apiUserKey*/public function __construct($username, $apiUserKey) {$this->_username = $username;$this->_apiKey = $apiUserKey;}/*** @param $raw* @param $salt* @return string*/private function _encodePassword($raw, $salt) {$salted = $this->_mergePasswordAndSalt($raw, $salt);$digest = hash('sha1', $salted, true);return base64_encode($digest);}/*** @param string $password* @param string $salt* @return string* @throws \InvalidArgumentException*/private function _mergePasswordAndSalt($password, $salt) {if (empty($salt)) {return $password;}if (false !== strrpos($salt, '{') || false !== strrpos($salt, '}')) {throw new \InvalidArgumentException('Cannot use { or } in salt.');}return $password . '{' . $salt . '}';}/*** @return array*/public function getHeaders() {$prefix = gethostname();$created = date('c');$nonce = base64_encode(substr(md5(uniqid($prefix . '_', true)), 0, 16));$salt = ''; // do not use real salt here, because API key already encrypted enough$passwordDigest = $this->_encodePassword(sprintf('%s%s%s', base64_decode($nonce), $created, $this->_apiKey), $salt);$wsseProfile = sprintf('X-WSSE: UsernameToken Username="%s", PasswordDigest="%s", Nonce="%s", Created="%s"', $this->_username, $passwordDigest, $nonce, $created);return array('Authorization: WSSE profile="UsernameToken"',$wsseProfile);}}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):PHP12345678910111213141516171819202122232425/*** @param int $calendarId* @param string $chkifleadoraccount* @return int*/public function getLeadAccount($calendarId,$chkifleadoraccount){$resArr = $this->getContainer()->get('oro_activity.manager.activity_context.api')->getActivityContext('Oro\Bundle\CalendarBundle\Entity\CalendarEvent',$calendarId);foreach($resArr as $re){if(($chkifleadoraccount == 'OroCRM_Bundle_AccountBundle_Entity_Account') && ($re['targetClassName'] == 'OroCRM_Bundle_AccountBundle_Entity_Account')){$contextid = $re['targetId']; //Account id}else if(($chkifleadoraccount == 'OroCRM_Bundle_SalesBundle_Entity_Lead') && ($re['targetClassName'] == 'OroCRM_Bundle_SalesBundle_Entity_Lead')){$contextid = $re['targetId'];}else{//exception}}return $contextid;}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.
YAML123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384send_appointment_mail:label: 'New Appointment'enabled: trueentity: Oro\Bundle\CalendarBundle\Entity\CalendarEventorder: 20actions_configuration:- '@tree':actions:- '@create_object':attribute: $.leadclass: Custom\Bundle\CalendarBundle\Service\GetContext- '@call_method':attribute: $.leadidobject: $.leadmethod: 'getLeadAccount'method_parameters: [$id,'OroCRM_Bundle_SalesBundle_Entity_Lead']- '@create_object':attribute: $.accountclass: Custom\Bundle\CalendarBundle\Service\GetContext- '@call_method':attribute: $.accidobject: $.accountmethod: 'getLeadAccount'method_parameters: [$id,'OroCRM_Bundle_AccountBundle_Entity_Account']- '@find_entity':parameters:class: OroCRM\Bundle\SalesBundle\Entity\Leadattribute: $.leadobjwhere:id: $.leadid- '@find_entity':parameters:class: OroCRM\Bundle\AccountBundle\Entity\Accountattribute: $.accobjwhere:id: $.accid- '@tree':conditions:'@not_empty': $.leadobj.emailactions:- @send_email_template:attribute: $.emailfrom: 'shreyas.s104@gmail.com'to: $.leadobj.emailtemplate: 'calendar_reminder'entity: $.data- @add_email_activity_target:email: $.emailtarget_entity: $.data- '@tree':conditions:'@not_empty': $.accobj.primaryEmailactions:- @send_email_template:attribute: $.emailfrom: 'shreyas.s104@gmail.com'to: $.accobj.primaryEmailtemplate: 'calendar_reminder'entity: $.data- @add_email_activity_target:email: $.emailtarget_entity: $.data# actions:#- '@foreach':# array: $calendar.owner.email# value: $.ownermail# actions:- @send_email_template:attribute: $.emailfrom: 'shreyas.s104@gmail.com'to: $calendar.owner.emailtemplate: 'calendar_reminder'entity: $.data- @add_email_activity_target:email: $.emailtarget_entity: $.datatriggers:send_appointment_mail:-event: createpriority: 0queued: truetime_shift: 5Here 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:
PHP1234567891011121314151617181920212223242526272829303132333435363738<?phpnamespace Custom\Bundle\CalendarBundle\Service;class GetContext{protected $container;/*** @param int $calendarId* @param string $chkifleadoraccount* @return int*/public function getLeadAccount($calendarId,$chkifleadoraccount){$resArr = $GLOBALS['kernel']->getContainer()->get('oro_activity.manager.activity_context.api')->getActivityContext('Oro\Bundle\CalendarBundle\Entity\CalendarEvent',$calendarId);foreach($resArr as $re){if(($chkifleadoraccount == 'OroCRM_Bundle_AccountBundle_Entity_Account') && ($re['targetClassName'] == 'OroCRM_Bundle_AccountBundle_Entity_Account')){$contextid = $re['targetId']; //Account id}else if(($chkifleadoraccount == 'OroCRM_Bundle_SalesBundle_Entity_Lead') && ($re['targetClassName'] == 'OroCRM_Bundle_SalesBundle_Entity_Lead')){$contextid = $re['targetId'];}else{}}return $contextid;}}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:
YAML12345parameters:custom_association.service.getcontext.class: Custom\Bundle\CalendarBundle\Service\GetContextservices:custom_association.service.getcontext:class: %custom_association.service.getcontext.class%Please find the Service for GetContext.php Called in Controller which is working fine to get the result id shown below:
PHP12345678910/*** @Route("/testcode/{id}", name="oro_calendar_event_getcontexttest", requirements={"id"="\d+"})***/public function chkworkingcode($id){$res = $this->get('custom_association.service.getcontext')->getLeadAccount($id,'OroCRM_Bundle_SalesBundle_Entity_Lead');print_r($res);}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:
PHP12345678910111213141516171819202122232425262728293031323334353637383940414243444546namespace Custom\Bundle\CalendarBundle\Service;use Symfony\Component\DependencyInjection\ContainerAwareInterface;use Symfony\Component\DependencyInjection\ContainerAwareTrait;use Symfony\Component\DependencyInjection\ContainerInterface;class GetContext implements ContainerAwareInterface{// use ContainerAwareTrait;// protected $container;/*** {@inheritdoc}*/public function setContainer(ContainerInterface $container = null){$this->container = $container;}/*** @param int $calendarId* @param string $chkifleadoraccount* @return int*/public function getLeadAccount($calendarId,$chkifleadoraccount){$resArr = $this->container->get('oro_activity.manager.activity_context.api')->getActivityContext('Oro\Bundle\CalendarBundle\Entity\CalendarEvent',$calendarId);foreach($resArr as $re){if(($chkifleadoraccount == 'OroCRM_Bundle_AccountBundle_Entity_Account') && ($re['targetClassName'] == 'OroCRM_Bundle_AccountBundle_Entity_Account')){$contextid = $re['targetId']; //Account id}else if(($chkifleadoraccount == 'OroCRM_Bundle_SalesBundle_Entity_Lead') && ($re['targetClassName'] == 'OroCRM_Bundle_SalesBundle_Entity_Lead')){$contextid = $re['targetId'];}else{}}return $contextid;}}In Services.yml changed the previous configuration of service custom_association.service.getcontext to given below:
YAML1234custom_association.service.getcontext:class: %custom_association.service.getcontext.class%calls:- [setContainer,['@service_container']]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 SSeptember 12, 2016 at 3:37 am in reply to: How to Send mail to Context whose appointment is set in calendar event #30455Hi 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:
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:YAML12345678910111213141516171819202122send_appointment_mail:label: 'New Appointment'enabled: trueentity: Oro\Bundle\CalendarBundle\Entity\CalendarEventorder: 20actions_configuration:- @send_email_template:attribute: $.emailfrom: 'madhur.h@gmail.com'to: $calendar.owner.emailtemplate: 'calendar_reminder'entity: $.data- @add_email_activity_target:email: $.emailtarget_entity: $.datatriggers:send_appointment_mail:-event: createpriority: 0queued: truetime_shift: 5In 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:
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.
123456789101112131415161718<table style="border-collapse: collapse; width: 480pt;" class="wrapper"><tbody><tr><td style="background-color: #ffffff; padding: 4pt;"><p><span>{{ entity.title }} is starting at {{ entity.start|date('F j, Y, g:i A') }}</span></p><p><strong>When: </strong><br />{{ calendar_date_range(entity.start, entity.end, entity.allDay, 'F j, Y', 1) }}</p><p><strong>Calendar: </strong><br />{{ entity.calendar }}</p><p>details:</p><p>{{ entity.description }}</p><p></p><p></p></td></tr><tr><td style="font-family: Arial, Helvetica, sans-serif; font-size: 10pt;"><a href="http://shreyas.demosite.com/%7B%7B%20oro_config_value('oro_ui.application_url')%20%7D%7D%7B%7B%20path('oro_calendar_event_view',%20%7B'id'%3A%20entity.id%7D)%20%7D%7D" target="_blank" rel="nofollow">more details »</a></td></tr></tbody></table>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 -
AuthorReplies