Struggling with this one. I've got a client script...
# suitescript
r
Struggling with this one. I've got a client script I can transform a Sales Order to an Item Fulfillment (via a custom record) and I'm attempting to setup a scheduled script. However, the scheduled script generates an error about missing default values. I have a log message of the values going into the transform, and there's nothing different. Anyone experience something like this before? I'm going to do a hard-code transform in the scheduled script to see if there's something else related to the generation code that pulls the values from the custom record we have.
s
Does the error message not say which values are missing?
r
it's very generic
Copy code
type: "error.SuiteScriptError",
   name: "INVALID_RCRD_TRANSFRM",
   message: "You have entered an invalid default value for this record transformation operation.",
   cause: {
      type: "internal error",
      code: "INVALID_RCRD_TRANSFRM",
      details: "You have entered an invalid default value for this record transformation operation.",
      userEvent: null,
   }
I'm providing these default values
Copy code
fromType: "salesorder"
toType: "itemfulfillment"
fromId: 328254

defaultValues:
{
   shipgroup: 1,
   inventorylocation: 19
}
One path pulls from the custom record, the other generates from SuiteQL But the values in my debug logs are the same
i.e. the transform method has the same inputs
s
"Missing" != "invalid" x not sure if that's significant?
r
that was my next thought
I'll write an expected check then can confirm in the client script execution with the scheduled script execution. fingers crossed that it's a type/invalid issue.
whelp, values === are the same for all the params of the transfrm.
All of these evaluate true in both the client script and the scheduled script
Copy code
328254 === recordId;
   'salesorder' === recordType.toString();
    19 === inventorylocation;
    1 === shipgroup;
    undefined === itemfulfillment;
s
Any other scripts or Workflows that might trigger differently by context?
Does it work of you remove the default values entirely?
Those two fields don't seem to be available as default values in the list here: https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/section_4267255811.html
r
They are required when the features "enable multi-line shipping" and "cross subsidiary fulfillment"
I'll see if I can bypass without any defaults
s
Do they have to be set as default values rather then just doing a setValue before save()
r
in this case, I'm not using Multi-line, which can exclude the shipgroup
previous scripts (suitelet) could not transform without the shipgroup specified
👍 1
but again, I can try happy path with at least the shipgroup removed.
just odd that everything goes in the same, the only difference being client script (and proved with suitelet) and scheduled script.
Next option, push this to the suitelet and have the scheduled script call the suitelet....
s
If one of those fields is not actually required I'd try removing that
r
removed all defaults with "allow cross sub" enabled
Copy code
cause: {
      type: "internal error",
      code: "VALID_LINE_ITEM_REQD",
      details: "You must have at least one valid line item for this transaction.",
      userEvent: null,
new error, but still not useful
s
I presume there are line items?
r
error matches the UI now as well
i.e. with defaultValues removed, behavior is the same. With it populated, different behavior
looks like yet another bug to log with support...oh wait, is it an enhancement because web services doesn't support x-sub fulfillments (REST problem). Looks like I'll try to push this via SuiteLet and have the scheduled script call that
s
Did you try leaving the inventorylocation default?,
r
yep, same error about defaults
all removed gave the line item error.
s
The latter is expected behaviour I think if no location is specified
r
agreed with nothing specified as it has no idea which to use for the location. although, it should be pretty smart as the UI does this for us.
but given the run around support is giving me, finding out everything other than the UI here is not so smart
s
Are you looping through the lines to set itemreceive before saving, or is the error coming on the transform rather than the save?
r
I can't even get to the details
I need to create the transform record before I can add the lines
This is the line-by-line snippet, and all the default values in the log match (true)
Copy code
const recIdMatch = 328254 === recordId;
    const recTypeMatch = 'salesorder' === recordType.toString();
    const invLocMatch = 19 === recordObject.defaultValues.inventorylocation;
    const shipGroupMatch = 1 === recordObject.defaultValues.shipgroup;
    const ifMatch = undefined === recordObject.defaultValues.itemfulfillment;

    log.debug({
      title: 'Match',
      details: `Id [${recIdMatch}] Type [${recTypeMatch}] Location [${invLocMatch}] Group [${shipGroupMatch}] IF [${ifMatch}]`
    })

    // Test without multiline enabled
    const defValues = { inventorlocation: recordObject.defaultValues.inventorylocation };

    try {
      newIfRecord = record.transform({
        fromType: recordType,
        fromId: recordId,
        toType: record.Type.ITEM_FULFILLMENT,
        isDynamic: true,
        defaultValues: defValues
      });
s
If that's a copy and paste, you have a typo in the defValues
r
woops this was the test I did with just the location, but you get the idea
good catch
let me try that
same error with the fix about valid line item
s
Is there a reason you are creating the record dynamically?
r
possibly from lingering headaches around serialized inventory.
s
Try it in standard, as these errors are the kind you get when setting things in the wrong order.
"The inventorydetail subrecord on each line of the edit machine (on the item fulfillment record) will only work when you manipulate the subrecord in a mode where isDynamic is false"
r
ok found the solution, not sure what's the difference though. I had "itemfulfillment" which is undefined. Removing that one solved it. My 'test' was flawed due to the typo you pointed out.
thanks for steering me clear 😉
s
Fun times. Glad it's working.
🙌 1
r
.giphy netsuite dance