Forums › Forums › OroCRM › OroCRM – How do I? Questions › Custom entity in the Sales channel, but it does not appear in the account view
This topic contains 9 replies, has 3 voices, and was last updated by schmalze 5 years, 11 months ago.
Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.
- CreatorTopic
- March 28, 2018 at 11:43 am #29548
Hi,
We have the following situation:
– We have a Sales channel
– We have added a custom entity to the Sales channel (there are some records in the entity)
– We have business customers and related accountsOur problem is that the custom entity does not appear neither in the business customer view nor in the account view. What other settings shall we do in order the custom entity can appear?
Thanks
Eszter - CreatorTopic
- AuthorReplies
- April 3, 2018 at 6:52 am #29549
Hi @schmalze
The described, unfortunately, not enough to understand what is wrong.
Could you please provide more details about ‘custom entity’, how it was created, how it’s linked with business customer and account, how and where you’d like it to appear?April 3, 2018 at 7:30 am #29550Hi Alexander,
1) We have created the custom entity the following:
– System / Entities / Entity management / Create entity
– First we added only one field to the entity (string type)
– We did the the schema update
– Than we added the custom entity to a Sales channel2) Link of the Account view screen: https://prnt.sc/j09yaq
We assumed based on the descriptions that the custom entity added to the sales channel will appear on the account view (like Lead and Opportunity), but it doesn’t. Why?3) Than we linked the previously created custom entity to Business Customer Entity, but it doesn’t help. We tried each relation type (we started the relation from the custom entity):
– many to many
– one to many –> this does not work at all, when we want to create the record, there is no possibility to select a business account
– many to oneThanks a lot for your help! Ask, if still not clear our problem.
Eszter
April 3, 2018 at 8:29 am #29551One more question, could you please tell me which version of OroCRM you use?
April 3, 2018 at 11:05 am #29552Here is the screen showing version: https://prnt.sc/j0dlt9
April 4, 2018 at 6:35 am #29553Hi Alexander,
Is there any news concerning my problem?
Thanks,
EszterApril 4, 2018 at 8:08 am #29554Hi @schmalze
This issue requires some investigation, I will get back to you ASAP with the answer.
Thank you for your patience!April 9, 2018 at 11:29 am #29555Hi Alexander,
I look forward to receiving your answer that will contribute a lot to our work with ORO CRM.
Thanks,
EszterMay 2, 2018 at 6:59 am #29556Hello, schmalze.
As I understood, you want to add custom entity, link it to Business Customer entity and to see this information to related account view page?
Let’s do a small example how you can do this.
1. Create new custom entity. In my case, it have test1 name and one string field:
2. Add new relation to Business Customer entity. In my case, the name of this new relation is test1Relation, type of relation is OneToMany to be able to select multiple values:
3. Add some records to test1 entity:
4. After this, you will be able to add test1 entity records as the value of test1Relation of Business Customer entity. Let’s add First and Third records to some customer:
After you dave the Customer, you will be able to see this data at view customer page:
5. To be able to see this data at related account page, you have to copy Oro/Bundle/SalesBundle/Resources/views/B2bCustomer/widget/customerInfo.html.twig template and add new tab declaration to it. Copy this template to application/commerce-crm-ee/app/Resources/OroSalesBundle/views/B2bCustomer/widget/customerInfo.html.twig (you can read documentation why we should copy the template here in Symfony documentation http://symfony.com/doc/2.8/templating/overriding.html) and add new tab declaration to this template.
As this is a very simple example, new tab just will show the data from the string fields of related test1 entities.
The tab declaration in my case looks like:
PHP12345678910111213141516171819{% set testContentTabData %}<div class="row-fluid"><br><div class="responsive-block">{% for relation in customer.test1Relation %}{{ UI.renderHtmlProperty('test relation'|trans, relation.testDtring) }}{% endfor %}</div></div>{% endset %}{% set tabs = tabs|merge([{'alias': 'oro_sales_b2bcustomer_test1' ~ uniqueSuffix,'widgetType': 'block','label': 'Custom entity'|trans,'content': testContentTabData,'url': null}]) %}And the full data of customerInfo.html.twig template will looks like:
PHP1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192{% import 'OroUIBundle::macros.html.twig' as UI %}{% import 'OroAddressBundle::macros.html.twig' as address %}{% set activeTab = app.request.get('_activeTab')|default(null) %}{% set uniqueSuffix = '_customer_' ~ customer.id ~ '_channel_' ~ channel.id %}{% set customer_general_info %}<div class="row-fluid"><br><div class="responsive-block">{{ UI.renderHtmlProperty('oro.sales.b2bcustomer.name.label'|trans,UI.entityViewLink(customer, customer.name, 'oro_sales_b2bcustomer_view')) }}{{ UI.renderHtmlProperty('oro.sales.lead.contact.label'|trans,UI.entityViewLink(customer.contact, customer.contact|oro_format_name, 'oro_contact_view')) }}</div><div class="responsive-block">{{ UI.renderHtmlProperty('oro.sales.b2bcustomer.shipping_address.label'|trans, address.renderAddress(customer.shippingAddress)) }}{{ UI.renderHtmlProperty('oro.sales.b2bcustomer.billing_address.label'|trans, address.renderAddress(customer.billingAddress)) }}</div></div>{% endset %}{% set tabs = [{'alias': 'oro_sales_b2bcustomer_general_info' ~ uniqueSuffix,'widgetType': 'block','label': 'oro.sales.sections.general'|trans,'content': customer_general_info,'url': null}] %}{% set tabs = tabs|merge([{'alias': 'oro_sales_b2bcustomer_leads' ~ uniqueSuffix,'widgetType': 'block','label': 'oro.sales.b2bcustomer.leads.label'|trans,'url': path('oro_sales_b2bcustomer_widget_leads', {'id': customer.id})}]) %}{% set tabs = tabs|merge([{'alias': 'oro_sales_b2bcustomer_opportunities' ~ uniqueSuffix,'widgetType': 'block','label': 'oro.sales.b2bcustomer.opportunities.label'|trans,'url': path('oro_sales_b2bcustomer_widget_opportunities', {'id': customer.id})}]) %}{% set testContentTabData %}<div class="row-fluid"><br><div class="responsive-block">{% for relation in customer.test1Relation %}{{ UI.renderHtmlProperty('test relation'|trans, relation.testDtring) }}{% endfor %}</div></div>{% endset %}{% set tabs = tabs|merge([{'alias': 'oro_sales_b2bcustomer_test1' ~ uniqueSuffix,'widgetType': 'block','label': 'Custom entity'|trans,'content': testContentTabData,'url': null}]) %}{% set tabPanelOptions = {useDropdown: isMobileVersion()} %}{% if activeTab %}{% set tabPanelOptions = tabPanelOptions|merge({activeTabAlias: 'oro_sales_b2bcustomer_' ~ activeTab ~ uniqueSuffix}) %}{% endif %}<div class="widget-content row-fluid"><div class="account-customer-title">{{ customer|oro_format_name|escape }}<div class="pull-right label label-info orocrm-channel-lifetime-value-label"><b>{{ 'oro.sales.b2bcustomer.lifetime.label'|trans}}:{{ oro_channel_account_lifetime(customer.account, channel)|oro_format_currency }}</b></div></div><div class="customer-without-border-tabs">{{ tabPanel(tabs, tabPanelOptions) }}</div></div>After that, if you work in prod environment, please clear the cache, to be sure that the overrided template will be shown instead of original one.
After that, open related account view page. This page should have new tab at the block of customer information with our test data:
May 8, 2018 at 3:45 am #29557Thanks a lot for the detailed manual
- AuthorReplies
The forum ‘OroCRM – How do I? Questions’ is closed to new topics and replies.