we want to set via map-reduce script the shipping ...
# suitescript
s
we want to set via map-reduce script the shipping method these seems to log as null but shows up in the ui any ideas ?
Copy code
fulfillmentRecord.shipmethod = //internal id of shipping methods
b
s
i need to call record.get value first i guess
b
it wont hurt, but you dont need to get the value before setting it
s
if i try to switch the shipping method i get this error
Copy code
error: Switching the shipping method to another carrier is an unsupported operation, because it requires reloading the item fulfillment form for that carrier.
b
same thing as in the ui actually
changing the shipping carrier reloads the form
s
right i was just thinking when you switch from usps for fedex it doesnt but to UPS does
b
set the shipping method in the ui and pay attention to the url as the page reloads
url parameters are transform default values you need to set
s
your right so any ideas for the map script to do this ?
b
learn how to use defaultValues
s
so I would need to figure out if I am switching the shipping before i call record.transform or before i call save
Copy code
var fulfillmentRecord = record.transform({
      fromType: record.Type.SALES_ORDER,
      fromId: data.id,
      toType: record.Type.ITEM_FULFILLMENT,
      isDynamic: false,
    });
b
depends on your logic for the shipping method
but you can probably just always use the default value whenever you use a certain shipping method
s
Copy code
var shiphash = {
      "9205+_case / 440": "4",
      "46727_mf_A": "4",
      "46727_mf": "4",
      "7638900426953_2pk_7638900426687_mf_A": "12867",
    };

    //build hash list to mat cch
    if (shipmethod === "3034" && shipmentweightusps > 1 && name in shiphash) {
      return shiphash[name];
    } else {
      log.debug({ title: "name", details: name });
      return shipmethod;
    }
b
determine which shipping method you are going to use before you do the transform
s
ok go it thanx
and pass into default value
Copy code
{shipmethod:id}
b
no
i dont usually remember the default values for item fulfillments because its an acronym
im fairly certain its not ship method
dont make the mistake assuming that default values are the same as fields
s
so fieldid ! = default value
b
not even the same concept
default values are different options to set fields on a record
s
i guess i have reading up to do
b
a lot of the time the options are the same as fields ids
s
in the url this is what gets added
Copy code
whence=&nsi=22516
that is the id of the shipping option
if anyone happens to know the name for default value of shipping method
Copy code
var fulfillmentRecord = record.transform({
      fromType: record.Type.SALES_ORDER,
      fromId: data.id,
      toType: record.Type.ITEM_FULFILLMENT,
      isDynamic: false,
      defaultValues: {????:shipid}
    });
b
Copy code
nsi
s
thanks
if that the value in the URL but i cant find in the docs , one morning i could wake up and they changed it
b
correct
s
that is scary
b
although at the very least there is an internal list of supported defaultValues
it will throw errors for unsupported ones
if you dont want to use nsi, you have to change the shipping method on the sales order
s
I guess if that happens it would be an easy fix, but luck would have it the day im on vaca