Alex Cameron
10/10/2024, 4:58 PMCeligo AI
10/10/2024, 4:58 PMAI generated answer (using internal Slack threads):In NetSuite, when you are in VIEW mode, the
N/currentRecord module does not contain all the field values. It only contains the recordtype and id. This is why you are getting undefined when trying to access custom field values using N/currentRecord.get().getValue() or N/currentRecord.get().getText().
However, you can use the recordtype and id to load the record using N/record.load() or N/search.lookupFields() to retrieve the custom field values. Here is an example of how you can do this:
javascript
define(['N/record', 'N/currentRecord'], function(record, currentRecord) {
function handleButtonClick() {
var rec = currentRecord.get();
var recordType = rec.type;
var recordId = rec.id;
// Load the record
var loadedRecord = record.load({
type: recordType,
id: recordId
});
// Get the custom field value
var customFieldValue = loadedRecord.getValue({ fieldId: 'customfield' });
}
return {
handleButtonClick: handleButtonClick
};
});
In this example, handleButtonClick is the function that is executed when the button is clicked. It first gets the current record and its type and id. Then it loads the record using N/record.load(). Finally, it retrieves the custom field value using getValue().
Remember, this approach will work only if the record is not in edit mode, as N/currentRecord does not work in edit mode.
******
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
10/10/2024, 4:58 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.864851952
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.858074427
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.849384665
Celigo AI
10/10/2024, 4:58 PM