Override key values in hybris map editor - sap-commerce-cloud

Is it possible to override the key values that are being populated for a map type attribute of an itemtype in backoffice? I've found the default MAP editor and spent almost 2hours debugging the application to see how the key values are populated but I couldn't find anything. For example, I want to display only 3 out of 5 enum values based on some logic when a new map entry is created.

I think you have two options.
You can create a custom editor to extends the map editor https://help.sap.com/docs/SAP_COMMERCE/5c9ea0c629214e42b727bf08800d8dfa/8bd4c25286691014b3f9876ca5816926.html
You can define a new itemType to store your pair key-values and use the Default Multi Reference Editor https://help.sap.com/docs/SAP_COMMERCE/5c9ea0c629214e42b727bf08800d8dfa/8bad002786691014924ba694583a1368.html to configure search options

Related

No key field(s) specified in attribute mapping. inDataDirector import bundle for Pimcore

The DataDirector import claims '[WARNING] No key field(s) specified in attribute mapping. Falling back to using all mapped fields as key fields. Please go to attribute mapping and set one or more fields as key fields which can be used to find already existing elements.'
All Pimcore Fields are already mapped.
How to fix it?
find the field which can be used as a key on 'Attribute mapping' /
'Attributzuordnung' (2) tab in dataDirector for your dataport.
Click on '<>' icon to open callback function editor
Activate the checkbox on top of callback function editor
Optionally, you can set this field as unique and mandatory in the class definition

Change object identifier in hybris backoffice

I wanted to add an extension in backoffice, so that it is possible for non-programming people to add new objects (of defined types) to the database.
I've almost done it:
I defined two items: offer and tile (their relation is one to many)
What i achieved is there is a possibility to add a new offer in the backoffice.
When you add it, and click to edit, you can also add a tile to this offer - either form drop-down list (if any tiles exist) or create a new tile, which will automatically be added to its table and realted to edited offer.
However, the representation of the drop-down list is unacceptable, see below:
screenshot from backoffice
as you can see, the identifier of an existing tile (within []) is its PK - which clearly is not a good identifier. I would like to inject there instead a value form one of tile's other attributes (which also is unique) so that someone could easily identify which tile to add.
Where is the mechanism responsible for it? How to override it. I tried to override toString method in the tile class, unfortunately to no avail
You need to customize the backoffice-config.xml for your custom Model. For your Tile model, you can use something like:
<context merge-by="type" type="Tile" component="base">
<y:base xmlns:y="http://www.hybris.com/cockpit/config/hybris">
<y:labels>
<y:label>nameOfTile</y:label>
</y:labels>
</y:base>
</context>

OrchardCMS Custom Forms and lookup fields

I can create custom form with Orchard Custom forms Module based on a Content Type.
Also i can add Enumerable field to the Content Type to show as combo box in created custom form.
But i can set list items of the enumerable field statically only.
How can i set this items based on result of a projection query or fill the combo box by any content items of a special content type dynamically?
You can't out of the box.
You could write your own module that provided a query driven combo field, but if you've not written a module before then you might want to start with writing a more simple field module first.
You might find the following useful:
Creating a custom field tutorial
I'd also look at the Orchard Source code for the projection module to see how they use queries.

Web Part with a custom property bound to a "choice" field from a content type?

I'm trying to make a custom property for a WebPart. The custom property should be a drop down with choices coming from a "choice" column from a content type. Is that even possible?
You have two options:
1) If your choices will never change then you can hardcode an enum with these values and use that as datatype for your custom property. SP will the automatically generate a drop down.
2) If you can't hardcode the values then you have to implement what is called an EditorPart where you can code the UI for handling entry of the custom property
You cannot data bind directly to a content type column as it does not exist as in a bindable form, only as an XML secification on the content type itself.
Better to specify the column as a lookup and databind to the list directly. However, that is not going to work well when you only want one lookup across multiple webs or site collections.
In that case create a list in a config site such as http://intranet/sites/config and code a lookup control to databind to that list. Then use the control in the webpart and in a custom field control on the content type.
A bit of work, but worth it if you require SharePoint edit control (versioning, security etc) access to the contents of the lookup and a single (changeable) source of data across the entire site.

Hiding a SharePoint Custom Field Type in Edit and Create mode

I am trying to create a Custom Field Type in SharePoint.
This control has it's value set based on another field in the same list.
Because of this requirement, this field should be displayed only in the Display Mode, and not in the Edit or Create mode.
How do I ensure this?
If I just code the ASCX control to not render a field, the field will show up like this in the Edit and Create mode.
alt text http://www.mannsoftware.com/blog/Lists/Photos/121308_0204_CrossSiteLo6.png
Generally you set the SPField.ReadOnlyField property to True to achieve the desired behaviour for any field. (Don't forget to SPField.Update accordingly!) There is an equivalent CAML attribute for list definitions, I believe.
That said, in your control class deriving from BaseFieldControl, you might just override the RenderFieldForInput() method and not call the base implementation to ensure nothing is rendered during Create or Edit. However, this would still render the field's table row in the form, which is probably not what you want. So to enforce the desired behaviour, use ReadOnlyField and override Update() in your SPField (not field control) class to always have it set to True.
It might be easier to just change this on a list-by-list basis by going to the Advanced section of the List Settings, setting Allow management of content types? to Yes, and then editing your content type to change the value of your field to 'hidden'.
Take a look at this blog post. I think it will give you some ideas. The concept uses different rendering templates based on the mode.
http://sharepoint.nailhead.net/2008/04/creating-rendering-template-that.html
Did you try and set the field as hidden?
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfield.hidden.aspx
Custom FORMS pages for new item and edit item (NewForm.aspx and EditForm.aspx) would be another way to achieve this.
Setting the ShowInEditForm and ShowInNewForm properties solved this for me.

Resources