I am trying to create a Work Order, this need to ...
# ask-stanley-ai
t
I am trying to create a Work Order, this need to be populated Subsidiary first so that assembly item field can be sourced and then I can pick. I can do that in UI but when I do that in suitescript, it says “You have entered an Invalid Field Value 1 for the following field: location” but it is populated correcly via UI and same thing happens for field assembly item. I am using dynamic mode to create record and populating subsidiary first and then location and then assembly item but none of it is working.
c
AI generated answer (using internal Slack threads):
Based on the conversations, it seems like you are encountering an issue with setting the 'location' field when creating a Work Order using SuiteScript in dynamic mode. This issue might be due to the order in which you are setting the fields. In NetSuite, some fields are dependent on others and need to be set in a specific order. For instance, the 'subsidiary' field often needs to be set before other fields as it can affect the sourcing of other fields. Here is a general approach you can follow: 1. Set the 'subsidiary' field first. 2. Then set the 'location' field. 3. Finally, set the 'assemblyitem' field. Also, ensure that the values you are setting for these fields are valid and exist in your NetSuite account. If you are still encountering the error, you might want to check the values you are setting. Make sure they are correct and exist in your NetSuite account. You can do this by logging the values before setting them. Here is a sample code snippet based on the conversations:
Copy code
javascript
var workOrder = record.create({
    type: record.Type.WORK_ORDER,
    isDynamic: true
});

workOrder.setValue({
    fieldId: 'subsidiary',
    value: subsidiaryId // replace with your subsidiary id
});

workOrder.setValue({
    fieldId: 'location',
    value: locationId // replace with your location id
});

workOrder.setValue({
    fieldId: 'assemblyitem',
    value: assemblyItemId // replace with your assembly item id
});

var workOrderId = workOrder.save({
    enableSourcing: true,
    ignoreMandatoryFields: true
});
Remember to replace
subsidiaryId
,
locationId
, and
assemblyItemId
with your actual values. ****** 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.849900782
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.847225
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.843990862
Please provide your feedback on this answer.
Thank you for your feedback