NetSuite Set Custom Segment Value on Vendor Bill

221 Views Asked by At

UPDATE: It's a Permission issue for Custom Role which I am using to execute the Restlet. Any idea which set of Lists/Setup/Transactions/Custom-Record to add on the Permission

I have a Custom Segment called Program, and the label for it on Netsuite is "cseg_program" which is one of the inputs in the Key, and the value is the internal ID associated with it. However, the code below still does not populate the data in the expense section. I am unsure if there are any restrictions around it as I do not see anything specific in the error logs.

Code changes made based on the : Question-73028265 Below is the snippet that creates the Expense data for the Vendor Bill.

 function buildBasicVendorRecord(reqBody) {
      // Creating Vendor Bill
      try {
        var VendorBill = record.create({
          type: record.Type.VENDOR_BILL,
          isDynamic: true,
          defaultValues: {
            entity: 123,
            customForm: 50,
          }
        });
        log.debug("Created vendor Bill :",VendorBill);

        reqBody.lines.forEach(function (line, i) {
          VendorBill.selectNewLine({
            sublistId: "expense",
          });
          for (var key in line) {
            if (!Utils.isNullOrEmpty(line)) {
              log.debug("Key 2:",key);
              log.debug("Value 2:",line[key]);
              VendorBill.setCurrentSublistValue({
                sublistId: "expense",
                fieldId: key,
                value: line[key],
              });
            }
          }
 
          VendorBill.commitLine({
            sublistId: "expense",
          });
        });
        log.debug("vendorBill after commitlines :", VendorBill);
        return VendorBill;
      } catch (e) {
        log.debug("Error value from here is :",e);
        throw e;
      }
    }
    
0

There are 0 best solutions below