Hey Tanya,
Could you please help, i am trying to achieve the following :
i have created 3 entities : Clients - Services - Projects
- Client Has Many Projects
- Client Has Many Services
- Projects Has Many Services
I would want to create new project and once i choose the client for this projects then when selecting services for the projects i want to get only services of the client selected for current project, just like the existing relation between call - contacts and account. In the call entity when creating new call for a specific account then in the contacts field you can choose only contacts that belong to this current account. please see attached screenshot.
this is the link to the question i put on the forum but had not response yet.
can you please help
Many thanks
How to add a custom filter with custom enum field values?
Collapse
X
-
Figured out why it was not working. The reason was browser cache. Once I did reload with
it started working. Thanks for the quick response tanya . Helped me a lot.Code:Ctrl + Shift + r
-
custom/Espo/Custom/Resources/metadata/clientDefs/Lead.json
with your content
And I have this filter in the list. Did you clear the cache?Code:{ "filterList": [ { "name": "newLeads" } ] }1 PhotoLeave a comment:
-
It started working somehow!
In Administrator when I got to label manager -> Lead -> presetFilters and change the value, where exactly is it updated.
In database(if yes, please specify which table / field) or Lead.jsonLast edited by theBuzzyCoder; 02-07-2018, 01:36 PM.Leave a comment:
-
Hello
Check if your json files are valid (maybe it's a part of json, if not I see extra commas). And filter name has to be "name": "newLeads" (lower camel case)Leave a comment:
-
Hi,
I am trying to do the same with leads but its not working
here's my code and path to file
/home/user/projects/www/espocrm/custom/Espo/Custom/SelectManagers/Lead.php
PHP Code:<?php namespace Espo\Custom\SelectManagers; use Espo\Modules\Crm\SelectManagers\Lead as LeadCrm; class Lead extends LeadCrm { protected function filterNewLeads(&$result) { $result['whereClause'][] = array( 'status=' => 'New' ); } } ?>
/home/user/projects/www/espocrm/custom/Espo/Custom/Resources/metadata/clientDefs/Lead.json
/home/codaxtr_user/projects/www/espocrm/custom/Espo/Custom/Resources/i18n/en_US/Lead.jsonCode:{ "filterList": [ { "name": "newLeads" } ] }
The filter "New Leads" is not showing up in the LeadsCode:{ "presetFilters": { "newLeads": "New Leads" } }
Last edited by theBuzzyCoder; 02-07-2018, 10:01 AM.Leave a comment:
-
Oh thanks ! you're right !
Really ... really .. thanks for your awesome support!
everything is ok for me now :-))
:-)))PHP Code:modified: custom/Espo/Custom/Resources/i18n/fr_FR/Contact.json new file: custom/Espo/Custom/Resources/metadata/clientDefs/Contact.json new file: custom/Espo/Custom/Selectmanagers/Contact.phpLeave a comment:
-
Hi
you added to entityDefs, needs to clientDefs folder
also check if custom/Espo/Custom/Resources/metadata/clientDefs/Contact.json is valid and is readable.Leave a comment:
-
A small question :
If i had my filter in => application/Espo/Modules/Crm/Resources/metadata/clientDefs/Contact.json
=> it's workingPHP Code:"filterList": [ - "portalUsers" + "portalUsers", + "MyFilter" ]
but i was thinking i could add it in custom folder => custom/Espo/Custom/Resources/metadata/entityDefs/Contact.json
i try to add
but .. not working.PHP Code:"filterList": [ - "portalUsers" + "portalUsers", + "MyFilter" ]
any reason ?
If i let it in application folder, maybe it will be replace but one of your file during an upgrade?
ThanksLeave a comment:
-
of course, you can set it in custom/Espo/Custom/Resources/i18n/fr_FR/Contact.jsonLeave a comment:
-
can we do the translate / presetFilters through "custom" folder (=> e.g. custom/Espo/Custom/Resources/i18n/fr_FR/Contact.json )
or should we do that in application/Espo/Resources/i18n/fr_FR/Global.json ?Leave a comment:
-
Hi
Translation for this is in "presetFilters" section.
Code:"presetFilters": { "customEnum": "custom - Enum" }Leave a comment:
-
Hi @tanya,
By the way, thanks for the responses.
I have added
$this->applyOrder('note.modified_at', true, $result);
$result['distinct'] = true;
and it did return the correct total count and was sorted to the latest activity.
here is my final code,
and Contact.json in clientdef,Code:protected function filterEmailSent(&$result) { $result['customJoin'] .= " LEFT JOIN note ON contact.id = note.parent_id AND note.deleted = 0"; $this->addAndWhere(array( 'note.type' => 'EmailSent' ), $result); $this->applyOrder('note.modified_at', true, $result); $result['distinct'] = true; } protected function filterHasCall(&$result) { $result['customJoin'] .= " LEFT JOIN note ON contact.id = note.parent_id AND note.deleted = 0"; $this->addAndWhere(array( 'note.related_type' => 'Call' ), $result); $this->applyOrder('note.modified_at', true, $result); $result['distinct'] = true; }
but the label doesnt work well when selected. Can you help? is this a bug?Code:"filterList": [ { "name":"emailSent", "label":"Email Sent" }, { "name":"hasCall", "label":"Has Call" } ]
1 PhotoLast edited by rgcadavos; 03-16-2017, 03:33 PM.Leave a comment:
-
application/Espo/ORM/DB/Query/Base.php method createSelectQuery
add endpoint before return, likerun query from log file in phpMyAdmin and analyze, what you need to add to query (possible contact.id duplicates because of one of JOIN)Code:if ($entityName == "Contact") { $GLOBALS['log']->error($sql);}Leave a comment:

Leave a comment: