·
8 min read

How to import default site and warehouse locations for a product using services (AIF)

I have recently had questions around how to import default site and warehouse locations for products when using AIF, so I thought an explanation and an example here might be helpful.

Three tables need to have the correct Dimension ID relationships setup in order for the item to
default the correct Site/Warehouse combination.

Within AX, you can set these defaults by going to :
Setup-Default Order Settings (Site specific)
Setup-Site Specific Order Settings (Site and Warehouse)

If you manually set those values, it adds the following records in each of the
tables below:

InventItemSalesSetup
InventItemPurchaseSetup
InventItemInventSetup

By adding values to the Default Order Settings, it creates a record with the 

InventDimID Field=AllBlank2
InventDimIDDefualt=’<site>’ (Dimension for the Site=1)

By adding values to the Site Specific Order settings, it creates a second
record with the following values:

InventDimID Field=’<location>’ (Dimension including the Warehouse)
InventDimIDDefualt=’<site>’

For importing these records, you need to follow a similar pattern…

The first record would have the following fields represented (all other fields
would match current default values)

InventDimID Field=AllBlank2
InventDimIDDefault=’<site>’ (Dimension for the Site=1)

The second record would have the following fields represented (all other fields
would match current default values)

InventDimID Field=’<site>’ (Dimension for the Site=1)
InventDimIDDefault=’<location>’ (Dimension including the Warehouse)

Here is a sample snippet (change the hard-coded values to match your data)…

            arrpursetup = new AxdEntity_InventItemPurchSetup[2];
            pursetup = new AxdEntity_InventItemPurchSetup() { ItemId = “CFL33” };
            pursetup.InventDimPurchSetup = new AxdEntity_InventDimPurchSetup[]
                                                { new AxdEntity_InventDimPurchSetup()
                                                    { InventDimId = “AllBlank2”}};

            pursetup.DefaultInventDimPurchSetup = new AxdEntity_DefaultInventDimPurchSetup[]
                                                        { new AxdEntity_DefaultInventDimPurchSetup()
                                                            { InventSiteId = “1”} };

            arrpursetup[0] = pursetup;

            pursetup = new AxdEntity_InventItemPurchSetup() { ItemId = “CFL33” };
            pursetup.InventDimPurchSetup = new AxdEntity_InventDimPurchSetup[]
                                                { new AxdEntity_InventDimPurchSetup()
                                                    { InventSiteId = “1”}};

            pursetup.DefaultInventDimPurchSetup = new AxdEntity_DefaultInventDimPurchSetup[]
                                                        { new AxdEntity_DefaultInventDimPurchSetup()
                                                            { InventLocationId = “11”} };

            arrpursetup[1] = pursetup;

            arrslssetup = new AxdEntity_InventItemSalesSetup[2];
            slssetup = new AxdEntity_InventItemSalesSetup() { ItemId = “CFL33” };
            slssetup.InventDimSalesSetup = new AxdEntity_InventDimSalesSetup[]
                                            { new AxdEntity_InventDimSalesSetup()
                                                { InventDimId = “AllBlank2”} };
            slssetup.DefaultInventDimSalesSetup = new AxdEntity_DefaultInventDimSalesSetup[]
                                                    { new AxdEntity_DefaultInventDimSalesSetup()
                                                        { InventSiteId = “1”} };
            arrslssetup[0] = slssetup;

            slssetup = new AxdEntity_InventItemSalesSetup() { ItemId = “CFL33” };
            slssetup.InventDimSalesSetup = new AxdEntity_InventDimSalesSetup[]
                                            { new AxdEntity_InventDimSalesSetup()
                                                { InventSiteId = “1”} };
            slssetup.DefaultInventDimSalesSetup = new AxdEntity_DefaultInventDimSalesSetup[]
                                                    { new AxdEntity_DefaultInventDimSalesSetup()
                                                        { InventLocationId = “11”} };
            arrslssetup[1] = slssetup;

            arrinventsetup = new AxdEntity_InventItemInventSetup[2];
            inventsetup = new AxdEntity_InventItemInventSetup() { ItemId = “CFL33” };
            inventsetup.InventDimInventSetup = new AxdEntity_InventDimInventSetup[]
                                                { new AxdEntity_InventDimInventSetup()
                                                    { InventDimId = “AllBlank2”} };
            inventsetup.DefaultInventDimInventSetup = new AxdEntity_DefaultInventDimInventSetup[]
                                                        { new AxdEntity_DefaultInventDimInventSetup()
                                                                { InventSiteId = “1”} };
            arrinventsetup[0] = inventsetup;

            inventsetup = new AxdEntity_InventItemInventSetup() { ItemId = “CFL33” };
            inventsetup.InventDimInventSetup = new AxdEntity_InventDimInventSetup[]
                                                { new AxdEntity_InventDimInventSetup()
                                                    { InventSiteId = “1”} };
            inventsetup.DefaultInventDimInventSetup = new AxdEntity_DefaultInventDimInventSetup[]
                                                        { new AxdEntity_DefaultInventDimInventSetup()
                                                                { InventLocationId = “11”} };
            arrinventsetup[1] = inventsetup;