Anyone know of a way around the ClientScript limit...
# suitescript
n
Anyone know of a way around the ClientScript limitation on setting inventory detail?
m
What limitation are you trying to get around?
n
It seems that Inventory Detail can't be updated from a Client script. I want to make a button on Item Fulfillments and Item Receipts thats visible on create, when clicked it should updated Inventory Detail according to defined logic… but it seems that client scripts deployed to IF’s and IR’a can only read and delete Inventory Detail but not create or update. I considered moving it to “pre populating” the inventory detail on beforeLoad but that also seems to not be a option.
d
code?
n
UE adds button in EDIT mode. CS function is triggered on btn click that sources data from a proxy and then runs the following code:
Copy code
if (response.body) {
        const responseBody = JSON.parse(response.body);
        if (responseBody.status !== "success") {
          alert("error occurred while getting the inventory detail");
          return;
        }

        const { binNumberId } = responseBody.data;

        if (!binNumberId) {
          alert("No bin number id found for the location");
          return;
        }

        // set the bin number id on the item fulfillment lines based on the response from the proxy
        const lineCount = rec.getLineCount({ sublistId: "item" });
        Array.from({ length: lineCount }, (_, i) => i).forEach((index) => {
          rec.selectLine("item", index);

          const hasInvDetSubrec = rec.hasCurrentSublistSubrecord("item", "inventorydetail");

          if (hasInvDetSubrec) {
            rec.removeCurrentSublistSubrecord("item", "inventorydetail");

            const invDetSubrec = rec.getCurrentSublistSubrecord("item", "inventorydetail");

            const quantity = invDetSubrec.getValue({ fieldId: "quantity" });

            // Add single new line with bin and all quantity
            invDetSubrec.selectNewLine("inventoryassignment");
            invDetSubrec.setCurrentSublistValue("inventoryassignment", "quantity", quantity);
            invDetSubrec.setCurrentSublistValue("inventoryassignment", "binnumber", binNumberId);
            invDetSubrec.commitLine("inventoryassignment");

            rec.commitLine("item");
          }
        });
      }
Error gets thrown on the
invDetSubrec.selectNewLine("inventoryassignment");
I also tried with
selectLine
and explicitly stating the line in the
setSublistValue
instead of doing current. Errors kept being thrown so I read NS docs and turns out that Inventory Detail is only available for "read" and "delete" in Client Scripts. Not edit.
cc; @David Na