I'm working on some scripting to update carrier in...
# suitescript
s
I'm working on some scripting to update carrier information on an Item Fulfillment and running into some roadblocks. The problem arises when I try to change the ship method on the fulfillment. I get the dreaded "Switching the shipping method to another carrier is an unsupported operation, because it requires reloading the item fulfillment form for that carrier". I've been trying to set the carrier form as well, but still run into issues. Here's an example of my code:
Copy code
switch (Number(stlToIfFields.custbody_shipping_company)) {
                  case 1:
                    // Fedex
                    stlToIfFields.carrierform = 'fedex'
                    stlToIfFields.shipcarrier = 'nonups'
                  case 332:
                    //Fedex Freight
                    stlToIfFields.carrierform = 'fedex'
                    stlToIfFields.shipcarrier = 'nonups'
                  case 2:
                    // UPS
                    stlToIfFields.carrierform = 'ups'
                    stlToIfFields.shipcarrier = 'ups'
                  default:
                    // Any other carriers
                    stlToIfFields.carrierform = 'ns'
                    stlToIfFields.shipcarrier = 'nonups'
                }

                log.debug(loggerTitle, `Record saved ID: ${stlToIfFields}`)

                var updateIfShippingValues = record.submitFields({
                  type: record.Type.ITEM_FULFILLMENT,
                  id: ifID,
                  values: stlToIfFields,
                  options: {
                    enableSourcing: false,
                    ignoreMandatoryFields: true
                  }
                })
b
do what you want to do in the ui first
pay attention to the url's query parameters when it reloads
query parameters in the url are usually default values you can set