How to hide the custom attribute in backoffice based on user roles? - sap-commerce-cloud

How to hide the custom attribute in backoffice based on user roles?
Only user with specific role should be able to edit that attribute from backoffice. For others it should be non editable.

Duplicate the context configuration and add principal configuration like the following:
The following configuration will be applied for all users :
<context type="Book" parent="GenericItem" merge-by="type">
<context component="editor-area">
<editorArea:editorArea>
<editorArea:tab name="hmc.tab.common" position="0">
<editorArea:section name="book.section.entities">
<editorArea:attribute qualifier="title"/>
</editorArea:editorArea>
</editorArea:tab>
</editorArea:editorArea>
</context>
</context>
Duplicate this configuration and add the principal property to the context, to be customized for specific users and add readOnly option to the attribute :
<context type="Book" parent="GenericItem" merge-by="type" principal="SpecificUserRoleGroup">
<context component="editor-area">
<editorArea:editorArea>
<editorArea:tab name="hmc.tab.common" position="0">
<editorArea:section name="book.section.entities">
<editorArea:attribute qualifier="title" readonly="true"/>
</editorArea:editorArea>
</editorArea:tab>
</editorArea:editorArea>
</context>
</context>

Related

How to hide an existing attribute in one tab and show it in the other tab

Hybris backoffice OOTB configuration comes with this attribute "last changes" shown in the administration tab as show below.
I have a requirement where I need to move the same attribute to the "history" tab as you can see above.
I have made the following changes to bring that attribute based on the code below
<context merge-by="type" parent="GenericItem" type="Product" component="editor-area" module="pcmbackoffice"
principal="backofficeadministratorrole,merchandisergroup,digitalmerchandisergroup,marketplacemanagergroup">
<editorArea:editorArea xmlns:editorArea="http://www.hybris.com/cockpitng/component/editorArea">
<editorArea:tab name="hmc.tab.product.change.logs" position="32" displayEssentialSectionIfPresent="false" merge-mode="merge">
<editorArea:section name="hmc.tab.product.change.logs">
<editorArea:attribute qualifier="SavedValues"
editor="com.hybris.cockpitng.editor.defaultmultireferenceeditor" merge-mode="merge">
<editorArea:editor-parameter>
<editorArea:name>readOnly</editorArea:name>
<editorArea:value>true</editorArea:value>
</editorArea:editor-parameter>
</editorArea:attribute>
</editorArea:section>
</editorArea:tab>
</editorArea:editorArea>
</context>
An the atribute appears fine in the history tab as below
Question:
I want to hide / remove the attribute "last changes" from the administration tab.How can I do that ? Please advise.
You can use the following code:
<context parent="GenericItem" type="Product" component="editor-area">
<editorArea:editorArea xmlns:editorArea="http://www.hybris.com/cockpitng/component/editorArea">
<editorArea:tab name="hmc.administration">
<editorArea:section name="hmc.section.saved.values" merge-mode="remove" >
<editorArea:attribute qualifier="SavedValues" merge-mode="remove"/>
</editorArea:section>
</editorArea:tab>
</editorArea:editorArea>
</context>

how to add my custom productcockpit extension as one of the options in hybris backoffice perspectives list mainslot

I have a customproductcockpit extension created and web module enabled.
i.e different URl to access localhost:9002/customproductcockpit.
Now I want to add this in Backoffice main slot as one of the perspective options.
Can some one please help me on this.
As shown in image I want to add one more option along with Administration and ProductCockpit.
Hi If you wish to add custom perspective in the back office, then you need to add another context in -backoffice-config.xml.
Sample Example:
<!-- start of employeemanager-->
<context merge-by="principal" component="explorer-tree" module="<custombackoffice extension name>" principal="employeemanager">
<explorer-tree:explorer-tree>
<explorer-tree:navigation-node id="backoffice_dashboard" merge-mode="remove"/>
<explorer-tree:navigation-node id="hmc_backoffice-workflow-inbox" merge-mode="remove"/>
<explorer-tree:navigation-node id="hmc_treenode_system" merge-mode="remove"/>
<explorer-tree:navigation-node id="hmc_treenode_catalog" merge-mode="remove"/>
<explorer-tree:navigation-node id="hmc_treenode_medias" merge-mode="remove"/>
<explorer-tree:navigation-node id="hmc_treenode_user" expanded-by-default="true" merge-mode="replace">
<explorer-tree:type-node code="UserGroup" id="hmc_typenode_usergroup" />
<explorer-tree:type-node code="Employee" id="hmc_typenode_employee"/>
</explorer-tree:navigation-node>
</explorer-tree:explorer-tree>
</context>
<!-- end of employeemanager-->

In Hybris backoffice how do I add another tab in explorer tree for managing (create, search, delete) instances of some items?

In Hybris Back Office, how do I add another tab in the explorer tree for managing (create, search, delete) instances of some items?
I can't really find anything on the subject.
Do I need to use the already available UI for it or add my own widget?
In your *-backoffice-config.xml file, you have to add something like this
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<config xmlns="http://www.hybris.com/cockpit/config"
xmlns:y="http://www.hybris.com/cockpit/config/hybris"
xmlns:wz="http://www.hybris.com/cockpitng/config/wizard-config"
xmlns:list-view="http://www.hybris.com/cockpitng/component/listView"
xmlns:editorArea="http://www.hybris.com/cockpitng/component/editorArea"
xmlns:explorer-tree="http://www.hybris.com/cockpitng/config/explorertree"
xmlns:simple-search="http://www.hybris.com/cockpitng/config/simplesearch"
xmlns:advanced-search="http://www.hybris.com/cockpitng/config/advancedsearch"
xmlns:df="http://www.hybris.com/cockpitng/component/dynamicForms"
xmlns:dsb="http://www.hybris.com/cockpitng/config/dashboard"
>
<context merge-by="module" parent="auto" component="explorer-tree">
<explorer-tree:explorer-tree xmlns:explorer-tree="http://www.hybris.com/cockpitng/config/explorertree">
<explorer-tree:navigation-node id="backoffice.myCustomItemType">
<explorer-tree:type-node code="MyCustomItemType" id="MyCustomItemType"/>
</explorer-tree:navigation-node>
</explorer-tree:explorer-tree>
</context>
<context type="MyCustomItemType" component="listview">
<list:list-view xmlns:list="http://www.hybris.com/cockpitng/component/listView">
<list:column qualifier="customAttribute1" />
<list:column qualifier="customAttribute2" />
</list:list-view>
</context>
</config>
Like way, you can configure "editorArea", "advanced-search", "create-wizard" etc by refering any OOTB backoffice-config.xml file.
Find this document for the steps.

Hybris - Adding new column in cscockpit search result

I am customizing the cscockpit for a module Order Search. Presently it shows three fields in the Order Search Result list. This setting is configured in a CockpitGroup.xml file named Order_OrderSearchResult_CockpitGroup.xml (Location: hybris\bin\ext-channel\cscockpit\resources\cscockpit\import\config)
My customized project is at location: hybris\bin\custom
How should I make a custom file of existing CockpitGroup.xml to include my new field?
The contents of Order_OrderSearchResult_CockpitGroup.xml are as below:
<?xml version="1.0" encoding="UTF-8"?>
<list-view unassigned-group-name="Other">
<group name="General">
<property qualifier="Order.creationtime" visible="true"/>
<property qualifier="Order.code" visible="true"/>
<property qualifier="Order.salesApplication" visible="true"/>
</group>
</list-view>
I want to add a new field Order.downloadDate.
I'm assuming you are not asking how to add <property qualifier="Order.downloadDate" visible="true"/> to that xml, and are asking instead how to configure the use of your customised file.
Look at the examples in "projectdata_cscockpit_ui_components.impex" delivered with the yacceleratorcockpits template. This will form part of your Accelerator project after modulegen.

How to retrieve items as a collection from a custom configuration section of an app.config file?

I have a custom configuration section defined in my app.config file. I need to get the tags and the sub tags within the created custom configuration section as a collection.
My config section is as follows,
<configSections>
<section name="myServices" type="NameSpace.ClassName, AssemblyName" />
</configSections>
<myServices>
<Tag1>
<subTag1 value="1"/>
<subTag2 value="2"/>
</Tag1>
<Tag2>
<subTag1 value="3"/>
<subTag2 value="4"/>
</Tag2>
</myServices>
My requirement is to get subtag values under each Tag as a collection.
Please help me to sort this out if any one gone through this before..
You can find very good artical here...
http://devlicio.us/blogs/derik_whittaker/archive/2006/11/13/app-config-and-custom-configuration-sections.aspx

Resources