While creating a sales order using suitetalk rest ...
# ask-stanley-ai
a
While creating a sales order using suitetalk rest api I am getting this error:
Copy code
"detail": "Error while accessing a resource. You have entered an Invalid Field Value 2 for the following field: currency.",
            "o:errorCode": "USER_ERROR"
My body of the query:
Copy code
{
    "entity": {
        "id": "1007523"
    },
    "tranDate": "2024-11-07",
    "custbody_celigo_etail_order_id": "9523",
    "subtotal": 28.79,
    "total": 32.25,
    "currency": {
        "id": "2"
    },
    ...
}
c
AI generated answer (using internal Slack threads):
Based on the conversations, the error you're encountering is likely due to the currency ID you're using not being accepted by the subsidiary associated with the customer on the sales order. In NetSuite, subsidiaries have specific currencies they can accept, and if you're trying to use a currency that isn't accepted by the subsidiary, you'll get an error. In the first conversation, a user was trying to set the currency on a sales order and kept getting an error. It was suggested that they check if the currency is selectable in the UI, as SuiteScript generally follows the same rules as the UI. The user found that the customer on the sales order had a subsidiary that couldn't accept the currency they were trying to use. To resolve this issue, you should check the subsidiary associated with the customer on your sales order and ensure that it can accept the currency you're trying to use. If it can't, you'll need to use a different currency that the subsidiary can accept. Here's a sample of how you might check the currency in SuiteScript:
Copy code
javascript
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);
}
****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.902818084
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.879993796
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.872199297
Please provide your feedback on this answer.