netsuite to set external id as string in suitescri...
# ask-stanley-ai
k
netsuite to set external id as string in suitescript
c
AI generated answer (using internal Slack threads):
****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ****** In NetSuite, you can set the external ID via SuiteScript, but there are some restrictions. From the conversations, it appears that you cannot set the external ID in a User Event Script at the 'beforeSubmit' stage. However, you can set it at the 'afterSubmit' stage. Please note that doing so may have performance implications as it will consume more resources. Here is a sample code snippet for setting the external ID in SuiteScript 2.1:
Copy code
javascript
newRecord.setValue({
    fieldId: 'externalid',
    value: '123',
    ignoreFieldChange: true
});
Remember, this code should be executed in the 'afterSubmit' stage of a User Event Script or in a different script type that allows setting of the external ID. Also, it's important to note that the external ID is typically used by systems outside of NetSuite. If you're using it for internal purposes, you might want to reconsider your approach as it could lead to additional costs. For list items such as product or currency, you cannot set a field by external ID directly. You would need to perform a search or query to filter by external ID, and then get the internal ID of the matching result. For more information on using external IDs, you can refer to the NetSuite Help Center article: [Using External IDs](https://system.netsuite.com/app/help/helpcenter.nl?fid=section_156334828635.html)
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.833282471
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.821746826
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.816925108
Please provide your feedback on this answer.