cancel
Showing results for 
Search instead for 
Did you mean: 

IMPEX: Document ID for required column/field not working

Former Member
0 Kudos

Hi,

I'm having issues while importing a custom type, Distribution Center which has the following fields (all required):

 <itemtype code="DistributionCenter" extends="GenericItem" jaloclass="com.bose.hybris.common.jalo.DistributionCenter">
     <deployment table="DistributionCenter" typecode="11202"/>
     <attributes>
         <attribute qualifier="code" type="java.lang.String">
             <persistence type="property"/>
             <modifiers optional="false"/>
         </attribute>
         <attribute qualifier="name" type="java.lang.String">
             <persistence type="property"/>
             <modifiers optional="false"/>
         </attribute>
         <attribute qualifier="address" type="Address">
             <persistence type="property"/>
             <modifiers optional="false"/>
         </attribute>
     </attributes>
 </itemtype>

To import our essential data for these distribution centers, I use Document IDs to assign the address to the DC. Just setting the owner of the address to the DC doesn't seem to work, the DC address reference remains empty in the HMC.

This is the essential data IMPEX:

 INSERT_UPDATE DistributionCenter; code[unique = true]; name; address(&dcID)
 ; "WSTG" ; "Bilzen, SC" ; dc1
 ; "SSTG" ; "Georgetown, AZ" ; dc2
 
 INSERT_UPDATE Address; &dcID; owner(DistributionCenter.code)[unique = true]; postalcode; town; region(isocode); country(isocode)
 ; dc1 ; "WSTG" ; "29016" ; "Bilzen" ; "US-SC" ; "US"
 ; dc2 ; "SSTG" ; "85353" ; "Georgetown"   ; "US-AZ" ; "US"

The error the IMPEX engine throws is the following:

 INSERT_UPDATE DistributionCenter;code[unique = true];name;address(&dcID)
 ,,,cannot create due to unresolved mandatory/initial columns, column 3: cannot resolve value 'dc1' for attribute 'address';WSTG;Bilzen, SC;dc1
 ,,,cannot create due to unresolved mandatory/initial columns, column 3: cannot resolve value 'dc2' for attribute 'address';SSTG;Georgetown, AZ;dc2
 

When the address field is optional for the DC, it works. So it seems the IMPEX engine can't handle Document IDs when the field is required? Is there a way around this, using plain IMPEX? (I'd rather not make address optional...)

Thanks for your input!

Vincent

SOLUTION:

A reference in both directions is needed. So DC -> Address and Address -> DC, like this:

 insert Address;&Item;country(isocode);owner(&Item)[allownull=true];postalcode;region(isocode);town
 ;Item0;US;Item1;29016;US-SC;Bilzen
 ;Item2;US;Item3;85353;US-AZ;Georgetown
 
 insert DistributionCenter;&Item;address(&Item)[allownull=true];code[allownull=true];name[allownull=true];owner(&Item)[allownull=true]
 ;Item1;Item0;WSTG;Bilzen, SC
 ;Item3;Item2;SSTG;Georgetown, AZ

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Vincent,

The only type with required Address type attribute I can find is Consignment which has following definition for this attribute in b2bcommerce-items.xml

         <itemtype code="Consignment"
             jaloclass="de.hybris.platform.ordersplitting.jalo.Consignment"
             extends="GenericItem" autocreate="true" generate="true">
             <deployment table="Consignments" typecode="2003" />
             <attributes>
                 ...
                 <attribute qualifier="shippingAddress" type="Address">
                     <modifiers initial="true" read="true" write="false"
                         optional="false" />
                     <persistence type="property" />
                 </attribute>
                 ...
             </attributes>
 
         </itemtype>

But unfortunately there's no impex scripts which import Consignment items.

What I would do in your case is to create manually some DistributionCenter item in hmc and then generate export script for DistributionCenter and Address types and try to re-import it (the script would require some clean up before importing it as you don't need to provide all the attributes that are generated).

Former Member
0 Kudos

Ok, so I exported the two types and cleaned it up. Turns out I needed a reference in both ways... So DC -> Address and Address -> DC. Here is the working IMPEX:

 insert Address;&Item;country(isocode);owner(&Item)[allownull=true];postalcode;region(isocode);town
 ;Item0;US;Item1;29016;US-SC;Bilzen
 ;Item2;US;Item3;85353;US-AZ;Georgetown
 
 insert DistributionCenter;&Item;address(&Item)[allownull=true];code[allownull=true];name[allownull=true];owner(&Item)[allownull=true]
 ;Item1;Item0;WSTG;Bilzen, SC
 ;Item3;Item2;SSTG;Georgetown, AZ

Thanks Vova!

Former Member
0 Kudos

Great. Glad that helped:)

Answers (0)