I am trying to get the custom form of a record fro...
# ask-stanley-ai
s
I am trying to get the custom form of a record from context.newRecord in an AfterSubmit user event script, but I am only getting null. What am I doing wrong?
c
AI generated answer (using internal Slack threads):
In NetSuite, the
context.newRecord
object in an AfterSubmit User Event script does not contain all the fields of the record. It only contains the fields that were present and loaded in the request that triggered the event. This is why you are getting null when trying to get the custom form of a record from
context.newRecord
in an AfterSubmit user event script. If you need to access the custom form of a record in an AfterSubmit User Event script, you will need to load the record again using the
N/record
module's
load
method. Here is an example:
Copy code
javascript
var record = context.newRecord;
var recordType = record.type;
var recordId = record.id;

var loadedRecord = record.load({
    type: recordType,
    id: recordId
});

var customForm = loadedRecord.getValue({
    fieldId: 'customform'
});
However, please note that loading a record in an AfterSubmit User Event script can have performance implications, as it requires an additional request to the server. If possible, consider using a BeforeSubmit User Event script instead, where the
context.newRecord
object will contain all the fields of the record. ****** 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.858299196
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.846003592
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.845055
Please provide your feedback on this answer.