1

I've been trying to add the Currency data under the Financial Tab for a vendor while creating a new vendor via suite script, Every single attempt results in different errors, but I somehow reduced it to

 Please enter value(s) for: Currency

pasting a sample of my code - I set the currency value right before the commitline method.

    rec.selectNewLine({
        sublistId: "currency",
        line: 1,
      });


      log.debug("Record data here :", rec);

      var currencies = getCurrenciesInformation();//all currency information available in NS account
      if (!isNullOrEmpty(currencies)) {
        for (var key2 in currencies) {
          if (!isNullOrEmpty(currencies[key2])) {
            //set the sublist data values.
            log.debug("iterated currency value:", key2);
            log.debug("iterated currencies[key2] value:", currencies[key2]);
            rec.setCurrentSublistValue({
              sublistId: "currency",
              fieldId: key2,
              value: currencies[key2].id,
            });
            rec.commitLine({
              sublistId: "currency",
            });
            log.debug("Record data here :", rec);
          }
        }

      }

I'm trying to get a successful response from the vendor created, with all the currencies under the Financial Tab.

Akhil KC
  • 76
  • 1
  • 8

1 Answers1

0

The solution was to have the new line created inside the loop.

        for (var key3 in currencies) {
          if (!isNullOrEmpty(currencies[key3])) {
              rec.selectNewLine({
                sublistId: "currency",
              });
              rec.setValue({
                sublistId: "currency",
                fieldId: "currency",
                value: currencies[key3].id,
              });

              rec.commitLine({
                sublistId: "currency",
              });
             
          }
        }

This created the record under the Currencies tab, watch out for the Primary Currency being set on the Vendor level.

Akhil KC
  • 76
  • 1
  • 8