what did the code look like?
# suitescript
b
what did the code look like?
e
Standard mode didn't work either.
m
what was the SS2.1 error?
e
FWIW
this
is not bound within arrow functions
so
this.lotNumbers
might not be around
e
first it was invalid value for location, then when I removed location, the error was invalid value for item (on the sublist)
e
ic
e
this.lotNumbers
is valid
I'll test without for sng
actually, I did test.
self = this
, same error
Copy code
var lot = _.find(self.lotNumbers, function(obj) {
    return Number(obj.itemInternalId) === Number(item.internalid) && processedLots.indexOf(obj.lotNumber) < 0;
});
Copy code
"You have entered an Invalid Field Value 8 for the following field: location",
anywho, lots of fun
t
stupid question I have had issues with header location vs line location in ss2.1 are all the products in the line level at the same location? ... I ended up having to set the location per line as well.
b
i personally will recommend simplified script when testing things
its makes it much easier submitting it as a support case
Copy code
/**
 * @NApiVersion 2.1
 * @NScriptType MapReduceScript
 */
define(["N/record"], function (record) {
  function getInputData() {
    var arr = [];
    for (var i = 0; i < 1; i++) {
      arr.push("{}");
    }
    return arr;
  }

  function map(context) {
    var salesOrder = record.create({ type: "salesorder", isDynamic: true });

    salesOrder.setValue({ fieldId: "entity", value: "9" });
    salesOrder.setValue({ fieldId: "location", value: "1" });
    salesOrder.setValue({
      fieldId: "memo",
      value: "I have waited twenty thousand years, but I will wait no longer.",
    });

    salesOrder.selectNewLine({ sublistId: "item" });
    salesOrder.setCurrentSublistValue({
      sublistId: "item",
      fieldId: "item",
      value: "75",
    });
    salesOrder.setCurrentSublistValue({
      sublistId: "item",
      fieldId: "quantity",
      value: 1,
    });
    salesOrder.setCurrentSublistValue({
      sublistId: "item",
      fieldId: "class",
      value: "1",
    });
    salesOrder.setCurrentSublistValue({
      sublistId: "item",
      fieldId: "amount",
      value: 1,
    });
    salesOrder.setCurrentSublistValue({
      sublistId: "item",
      fieldId: "taxcode",
      value: "-600",
    });

    var inventoryDetail = salesOrder.getCurrentSublistSubrecord({
      sublistId: "item",
      fieldId: "inventorydetail",
    });
    inventoryDetail.selectNewLine({ sublistId: "inventoryassignment" });
    inventoryDetail.setCurrentSublistValue({
      sublistId: "inventoryassignment",
      fieldId: "issueinventorynumber",
      value: "35",
    });
    inventoryDetail.setCurrentSublistValue({
      sublistId: "inventoryassignment",
      fieldId: "quantity",
      value: 1,
    });

    inventoryDetail.commitLine({ sublistId: "inventoryassignment" });

    salesOrder.commitLine({ sublistId: "item" });

    salesOrder.save();
  }

  function reduce(context) {
    log.debug("reduce context", context);
  }

  function summarize(summary) {
    log.debug("summary", summary);

    if (summary.inputSummary.error) {
      log.error({
        title: "Input Error",
        details: summary.inputSummary.error,
      });
    }

    summary.mapSummary.errors
      .iterator()
      .each(function (key, error, executionNumber) {
        log.error({
          title:
            "Map error on key: " +
            key +
            ", executionNumber: " +
            executionNumber,
          details: error,
        });
        return true;
      });

    summary.reduceSummary.errors
      .iterator()
      .each(function (key, error, executionNumber) {
        log.error({
          title:
            "Reduce error on key: " +
            key +
            ", executionNumber: " +
            executionNumber,
          details: error,
        });
        return true;
      });
  }

  return {
    getInputData: getInputData,
    map: map,
    //reduce: reduce,
    summarize: summarize,
  };
});
e
yeah, code works fine for inventory transfer
b
code that hardcodes everything makes it easier to test and give to support
i can tell you that at least the code i shared works fine in 2.0 and 2.1
its also easy to switch back and forth from 2.0 to 2.1 since its only uses es5 syntax
e
es5 syntax works, so I must be missing something. I don't see what, as the script doesn't get past the location line
b
my guess is the entity
umm, by process of elimination
e
the constant is the same in both tests though
this method is in a class that extends a base class though
shouldn't matter
b
dont do fancy stuff, hard code it like i did
e
so, I guess I can let the end user know all they need to do is edit the script to create the sales order from now on. 😉
b
if it works hardcoded, its messed up elsewhere
e
of course hard coding works
lol
t
if its working hard coded I would do a log.debug of the Constants just before you set the entity so you can be sure its fully available in the scope of the function. 2.1 changes a lot of the scopes and I have left variables out
b
something that can happen is that 2.0 has wrong const scope while 2.1 has correct scope
if you relied on it being wrong, your script could fail
@Tim Pilgrim when location is on the line level, the header location is only used for classification purposes
👍 1
e
Well, lesson learned. I forgot to upload my updated constants file. Wow, I must need more sleep
hours, and hours, wow.
it worked in the ss2 file because I just put the constants in the file as a var since my constants.js is 2.1. live and learn, again