Chris
03/28/2025, 6:52 AMCeligo AI
03/28/2025, 6:52 AMAI generated answer (using internal Slack threads):To get the record id in a script, you can use the
currentRecord.id
property. However, it's important to note that this property is only available after the record has been saved. If you're trying to access the record id in a client script before the record is saved, the id will not be available.
If you need to access the record id immediately after the record is saved, you can use an afterSubmit User Event script. In the afterSubmit function, you can access the new record id using context.newRecord.id
.
Here's a sample code snippet for an afterSubmit User Event script:
javascript
function afterSubmit(context) {
var recordId = context.newRecord.id;
// You can now use the recordId
}
If you're trying to get the internal ID of a field from its script ID, you can use the N/query
module to create a query that retrieves the internal ID and script ID of all custom fields. Here's a sample code snippet:
javascript
require(['N/query'], query => {
const myQuery = query.create({
type: query.Type.CUSTOM_FIELD
});
myQuery.columns = [
myQuery.createColumn({
fieldId: 'internalid'
}),
myQuery.createColumn({
fieldId: 'scriptid'
})
];
const resultSet = myQuery.run();
console.log(resultSet.asMappedResults());
});
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
03/28/2025, 6:52 AMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.831780553
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.825518191
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.824894488
Celigo AI
03/28/2025, 6:52 AM