Rob
10/09/2024, 2:14 PMCeligo AI
10/09/2024, 2:14 PMAI generated answer (using internal Slack threads):Based on the conversations provided, it appears that it is possible to update certain aspects of a saved search via script in NetSuite. However, there are limitations to what can be updated. In one of the threads, a user shared a SuiteScript code snippet that updates the owner of multiple saved searches. The script loads each saved search record, updates the owner field with a new owner's internal ID, and then saves the updated record. However, another user mentioned that the Saved Search is not fully exposed to SuiteScript, implying that there might be limitations to what can be updated via script. In another thread, it was mentioned that the search results or search creation page is not scriptable, meaning you cannot execute a script on the page of saved search results when the user views it to trigger some action or give them a popup. Here is the code snippet shared in the thread:
/**\n * @NApiVersion 2.x\n * @NScriptType ScheduledScript\n */
define(['N/search', 'N/runtime', 'N/record'], function(search, runtime, record) {
function execute(context) {
// Set the new owner's internal ID
var newOwnerId = '12345';
// Get the list of saved searches to update
var savedSearchList = getSavedSearchesToUpdate();
// Iterate through the saved searches and update the owner
for (var i = 0; i < savedSearchList.length; i++) {
try {
var savedSearchId = savedSearchList[i];
// Load the saved search record
var savedSearchRecord = record.load({
type: record.Type.SAVED_SEARCH,
id: savedSearchId
});
// Update the owner field with the new owner's internal ID
savedSearchRecord.setValue({
fieldId: 'owner',
value: newOwnerId
});
// Save the updated record
savedSearchRecord.save();
log.debug('Updated Saved Search', 'ID: ' + savedSearchId);
} catch (e) {
log.error('Error Updating Saved Search', 'ID: ' + savedSearchId + ' | Error: ' + e.message);
}
}
}
function getSavedSearchesToUpdate() {
// Replace this with the search criteria or the list of saved search IDs you want to update
var savedSearchList = [
'search_id_1',
'search_id_2',
// ...
];
return savedSearchList;
}
return {
execute: execute
};
});
******
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/09/2024, 2:14 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.868773341
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.861787081
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.861038387
Celigo AI
10/09/2024, 2:15 PM