https://netsuiteprofessionals.com logo
m

Marwan

05/08/2022, 9:14 AM
Hi all, I am trying to set the currency on a sales order from a RESTlet, using the following code:
Copy code
let currID;
          srch = search.create({
            type: "currency",
            filters: [["symbol", "is", context["currency"]]],
          });
          searchResultCount = srch.runPaged().count;
          if (searchResultCount > 0) {
            currID = srch.run().getRange(0, 1)[0].id;
            salesorder.setValue("currency", currID);
          }
But I keep getting this error
Copy code
"status": {
        "code": 500,
        "message": {
            "type": "error.SuiteScriptError",
            "name": "INVALID_KEY_OR_REF",
            "message": "You have entered an Invalid Field Value 2 for the following field: currency",
While in this case
2
is the correct ID Any ideas?
b

battk

05/08/2022, 9:49 AM
suitescript generally follows the same rules as the ui
so you can debug by creating the same sales order in the ui to see if that currency is selectable
m

Marwan

05/08/2022, 9:50 AM
Ok, will try... Thanks ❤️
b

Brian Brown

05/10/2022, 12:45 PM
@Marwan most likely the CUSTOMER on that SALES ORDER has a SUBSIDIARY that cannot accept that CURRENCY
👍 1
m

Marwan

05/10/2022, 1:53 PM
@Brian Brown Yes, that was the problem.
b

Brian Brown

05/10/2022, 1:56 PM
OK good @Marwan glad you were able to resolve