how do i record.load() a custom record
# ask-stanley-ai
i
how do i record.load() a custom record
c
AI generated answer (using internal Slack threads):
To load a custom record in SuiteScript, you need to use the
record.load
method. This method requires the type of the record and the id of the record you want to load. Here is a basic example:
Copy code
javascript
var record = require('N/record');
var myRecord = record.load({
    type: 'customrecord_my_custom_record', 
    id: '123'
});
In the above example, replace
'customrecord_my_custom_record'
with the script id of your custom record type and
'123'
with the internal id of the record you want to load. If you want to load a custom record using an external id, you can use SuiteQL to get the internal id first. Here is an example:
Copy code
javascript
var record = require('N/record');
var query = require('N/query');

var myExternalId = 'myExternalId';
var myRecordType = 'customrecord_my_custom_record';

var sql = "SELECT id from " + myRecordType + " where externalid = '" + myExternalId + "'";
var internalId = query.runSuiteQL(sql).asMappedResults()[0].id;

var myRecord = record.load({
    type: myRecordType, 
    id: internalId
});
In the above example, replace
'myExternalId'
with your external id, and
'customrecord_my_custom_record'
with the script id of your custom record type. ****** 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.828063548
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.820927799
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.813456893
Please provide your feedback on this answer.