cancel
Showing results for 
Search instead for 
Did you mean: 

Mandatory Header not working in Target xml in datahub

bidyadhar_tripathy
Participant
0 Kudos
180

Hi All,

We have mandatory attributes in Product in hybris so made them as mandatory header - true in Target xml for product in datahub. But when we don't pass value for those attributes then we are getting impex error at hybris end not at datahub end.

As we already mentioned mandatory header for those attributes, we are expecting errors should be thrown at datahub end not at hybris.

                 <item>
                     <type>TargetPIMProduct</type>
                     <description>Hybris Platform representation of Products</description>
                     <updatable>true</updatable>
                     <canonicalItemSource>CanonicalProduct</canonicalItemSource>
                     <status>ACTIVE</status>
                     <dependencies>
                             <dependency>TargetWeightUnitEnum</dependency>
                             <dependency>TargetDimensionUnitEnum</dependency>
                     </dependencies>
                     <attributes>
                         <attribute>
                             <name>catalogNumber</name>
                             <localizable>false</localizable>
                             <collection>false</collection>
                             <transformationExpression>catalogNumber</transformationExpression>
                             <exportCode>catalogNumber</exportCode>
                             <mandatoryInHeader>true</mandatoryInHeader>
                         </attribute>
                     </attributes>
                 </item>

Any pointers on this issue ?

Accepted Solutions (1)

Accepted Solutions (1)

former_member224482
Active Contributor
0 Kudos

The mandatoryInHeader attribute is only used for Commerce localized import to know which attributes are needed for the minimal localized import data.

It does not filter/validate that the attribute are populated.

bidyadhar_tripathy
Participant
0 Kudos

Hi Robin,

Thank you for your response. Is there any way to validate those mandatory attributes at datahub end ? so that we can avoid the errors thrown at hybris.

Slava
Advisor
Advisor
0 Kudos

There is no easy way to enforce them in the item model. The only mandatory fields for DataHub are those, which are marked as primaryKey in the canonical model, so if their values are not provided DataHub will complain. Everything else is optional and not know whether it's required or not until attempted to be published to a target system. The reason is because the same attribute may be required in one target system and optional in the other.

However, specifically related to mandatoryInHeader marker: they usually specified for the key attributes and therefore will be caught by DataHub, because the key attributes are required.

You can enforce "not null"/"not blank" checks but in custom handlers. It's not possible in the model.

Slava
Advisor
Advisor
0 Kudos

A bit more explanation to Robin's answer.

The data in the impex sent to ECP are split into blocks with headers for each of the block. This reduces data duplication. First, DataHub sends non-localized attributes because they need to be sent only once. Then it sends localized attributes (a block per each locale). As Robin said the mandatoryInHeader is used to specify the attributes, which work as identifiers and usually accompany those attributes having [unique = true] in the exportCode and sent with both localized and non-localized attributes.

Consider them as hints for impex header generation. For example, we have a Product type that has a key attribute 'code', a basic (non-localized) attribute 'unit', and a localized attribute 'name'. We mark 'code' attribute as mandatoryInHeader to always include it in the headers, so the generated impex is this:

INSERT_UPDATE Product; code[unique = true]; unit

; 123 ; piece

INSERT_UPDATE Product code[unique = true]; name[language = 'en']

; 123; the name

INSERT_UPDATE Product code[unique = true]; name[language = 'de']

; 123; der Name

Without mandatoryInHeader it would not be included in the localized blocks

bidyadhar_tripathy
Participant
0 Kudos

Hi ,

Thank you for the explanation.

Could you please share any sample custom handler to validate "not null"/"not blank" attribute values.

former_member224482
Active Contributor
0 Kudos

Example :

 <item>
   <type>TargetYMKTAbandonedCartCampaignReference</type>
   <exportCode>Association=InteractionInteractionAdditionalObjRef</exportCode>
   <description>Hybris Marketing CUAN_IMPORT_SRV Association InteractionInteractionAdditionalObjRef</description>
   <canonicalItemSource>CartCanonical</canonicalItemSource>
   <filterExpression filteredItemPublicationStatus="SUCCESS">ymktTrackingId != null and !ymktTrackingId.isEmpty()</filterExpression>
   <attributes>
     ......

See the filterExpression part. The entire canonical item will be transformed into a target item only if the filterExpression's result is true.

bidyadhar_tripathy
Participant
0 Kudos

Hi ,

Thank you for the response. I tried with your sample example and it is working fine. But I am not seeing any error message at datahub end, otherwise It will be difficult for us to understand why Canonical Items are not published as there is no stack trace.

When an attribute is null/blank, we are expecting error message related to the attribute something like below. Value for attribute catalogNumber of canonical item CanonicalProduct is blank or null.

former_member224482
Active Contributor
0 Kudos

Filtering Canonical Items with SpEL Before Publication

I do not know the logging outcome of the other filteredItemPublicationStatus.
Feel free to try them out.

Answers (0)