1

Need help adding "packages" to Item Fulfillment records to allow CSRs to see which items were shipped out under which tracking numbers. I can instantiate an ItemFulfillment record and an ItemFulfillmentPackageList object but the ItemFulfillmentPackageList object is always null - can't figure out how to add ItemFulfillmentPackage objects to the collection. I've tried various methods to assign to the ItemFulfillmentPackageList object without luck. Creating an array of ItemFulfillmentPakage objects is the latest attempt. Here's the code I have.

                foreach (DataRow dr in dt.Rows)
                {
                    try
                    {
                        ItemFulfillment ifRecord = new ItemFulfillment();
                        ifRecord.packageList = new ItemFulfillmentPackageList();
                        ifRecord.internalId = dr["Item Fulfillment Internal ID"].ToString();

                        ItemFulfillmentPackage ifp = new ItemFulfillmentPackage();

                        ifp.packageDescr = dr["Package Description"].ToString();
                        ifp.packageTrackingNumber = dr["detail_tracking_information"].ToString();

                        ItemFulfillmentPackageList ifpl = new ItemFulfillmentPackageList();

                        Object[] objPackages = new Object[1];
                        objPackages[1] = ifp;

                        ifpl = (ItemFulfillmentPackageList)objPackages;

                        ifRecord.packageList = ifpl;

                        ifpl.replaceAll = false;

                        WriteResponse res = _service.update(ifRecord);

                        if (res.status.isSuccess)
                        {
                            ;
                        }
                        else if (res.status.isSuccessSpecified)
                        {
                            ;
                        }
                        else
                            displayError(res.status.statusDetail);
                    }
                    catch (Exception ex)
                    {
                        _logger.error(String.Format("Error in updateItemFulfillment DR method. {0}", ex.Message));
                        throw new Exception(String.Format("Error in updateItemFulfillment DR method. {0}", ex.Message));
                    }
                }
dubtime
  • 11
  • 4

2 Answers2

0

Make sure that you configure your search preferences so that bodyFieldsOnly is true; by default its set to false and it won't load sublist items.

0

I had the same issue. What I ended up doing is to create the Item Fulfillment transaction, with all related line level information and add this to NetSuite.

After this, I search for the Item Fulfillment that I just added and add the tracking information to the record. I do this by checking which package field is not equal to null and adding the information to that package list.

In my case, only one tracking number is used per order and all packages will contain this. You can modify this to add tracking references as needed.

The variable called "msg" is a shipment notification which contains all shipping information.

My code:

TransactionSearch xactionSearch = new TransactionSearch();

TransactionSearchBasic xactionBasic = new TransactionSearchBasic();
xactionBasic.createdFrom = new SearchMultiSelectField();
xactionBasic.createdFrom.@operator = SearchMultiSelectFieldOperator.anyOf;
xactionBasic.createdFrom.operatorSpecified = true;
xactionBasic.createdFrom.searchValue = new RecordRef[1];
xactionBasic.createdFrom.searchValue[0] = new RecordRef { internalId = "SO Internal ID"};

xactionSearch.basic = xactionBasic;
if (useTba = "true".Equals(_custSettings["login.useTba"]))
    login();
SearchResult res = _service.search(xactionSearch);
ReadResponse res2 = new ReadResponse();

for (int i = 0; i < res.recordList.Length; i++)
{
   if (res.recordList[i] is ItemFulfillment)
   {
      if (useTba = "true".Equals(_custSettings["login.useTba"]))
         login();
      res2 = _service.get(new RecordRef { internalId = ((ItemFulfillment)res.recordList[i]).internalId, type = RecordType.itemFulfillment, typeSpecified = true });
    }
}

        ItemFulfillment item = (ItemFulfillment)res2.record;
        ItemFulfillment NewItem = new ItemFulfillment { internalId = item.internalId };

        //Fedex
        if (item.packageFedExList != null)
        {
            if (item.packageFedExList.packageFedEx != null)
            {
                for (int i = 0; i < item.packageFedExList.packageFedEx.Length; i++)
                {
                    item.packageFedExList.packageFedEx[i].packageTrackingNumberFedEx = msg.trackingRef;
                }
            }
            NewItem.packageFedExList = item.packageFedExList;
        }


        if (item.packageList != null)
        {
            if (item.packageList.package != null)
            {
                for (int i = 0; i < item.packageList.package.Length; i++)
                {
                    item.packageList.package[i].packageTrackingNumber = msg.trackingRef;
                }
            }
            NewItem.packageList = item.packageList;
        }

        //UPS
        if (item.packageUpsList != null)
        {
            if (item.packageUpsList.packageUps != null)
            {
                for (int i = 0; i < item.packageUpsList.packageUps.Length; i++)
                {
                    item.packageUpsList.packageUps[i].packageTrackingNumberUps = msg.trackingRef;
                }
            }
            NewItem.packageUpsList = item.packageUpsList;
        }

        //Usps
        if (item.packageUspsList != null)
        {
            if (item.packageUspsList.packageUsps != null)
            {
                for (int i = 0; i < item.packageUspsList.packageUsps.Length; i++)
                {
                    item.packageUspsList.packageUsps[i].packageTrackingNumberUsps = msg.trackingRef;
                }
            }
            NewItem.packageUspsList = item.packageUspsList;
        }

        if (useTba = "true".Equals(_custSettings["login.useTba"]))
            login();
        _service.update(NewItem);
Charl
  • 812
  • 1
  • 8
  • 22