Pages

Monday, July 29, 2019

Create warehouse addresses through code


  

 InventLocation                           warehouse;
    LogisticsPostalAddressView      postalAddressView;
    LogisticsPostalAddress              postalAddress;
    LogisticsEntityLocationMap       locationMap;
    container                                   role, roleMap;
    Map                                         LocationRoleMap;
    LogisticsPostalAddressEntity    postalAddressEntity  = new LogisticsPostalAddressEntity();
    ;
    warehouse                                            = InventLocation::find('CR004');
    postalAddressView.Street                    = 'Test street222';
    postalAddressView.City                       = 'Tcity';
    postalAddressView.State                     = '';
    postalAddressView.ZipCode               = '622001';
    postalAddressView.CountryRegionId   = 'SASCO';
    postalAddressView.LocationName       = 'TDlvAddr';
    postalAddress        = postalAddressEntity.createPostalAddress(postalAddressView);
    locationMap           = LogisticsEntityLocationMap::find(tableNum(InventLocationLogisticsLocation), warehouse.RecId, postalAddress.Location);
    locationMap.Entity                      = warehouse.RecId;
    locationMap.Location                 = postalAddress.Location;
    locationMap.IsPostalAddress     = NoYes::Yes;
    locationMap.IsPrimary               = NoYes::Yes;
    locationMap.IsPrivate                = NoYes::No;
    LocationRoleMap       = LogisticsLocationEntity::getDefaultLocationRoleFromEntity(tableName2id("InventLocation"));
    roleMap                     = map2Con(LocationRoleMap);
    role                            = conpeek(roleMap, 1);
    locationMap.addEntityLocation(role ,true);



thanks. http://axcorner.blogspot.com/2014/01/create-warehouse-addresses-through-code.html