Hi. I am implementing a Mass Update Script found i...
# suitescript
m
Hi. I am implementing a Mass Update Script found in Anser ID: 35952. As written, it updates the script owner. I want to update the Notify Group and have done so by updating the script. The issue I have is, I want to schedule theses mass updates to run every day to update scripts that don't have a notify group. But for some reason, Notify Group is not an available criterion to filter on. I was trying to filter using system notes, which I can use to find scripts with a notify group, but does not work well for the inverse of that. Has anyone dealt with this before? Have any ideas? Or Do you see an issue with running these mass updates every day and having them check every script. The Mass Update appears to skip the script if it already has a notify group, or the notify group is the same. It does not log another update to System Notes. Does it sound like a bad practice to schedule this and have it run over records that had already been updated? Here is the script - for reference
/**
 
*@NApiVersion 2.0
 
*@NScriptType MassUpdateScript
 
*/
define(['N/record'], function(record) {
    
function each(params) {
        
var recType = params.type;
        
var recNum = params.id;
        
var newRec = record.submitFields({
          
type: recType,
          
id: recNum,
          
values: {
            
notifygroup: 86260234, _// 86260234 => Script Notify Group_
          
},
        
});return newRec;
      
}
    
return {
        
each: each
    
}
});
s
This can pretty easily be done in an MR/scheduled instead, notify owner/group are part of the query module and can be used to restrict your entry point there.
Copy code
exports.execute = function execute(context) {
        var queryMain = query.create({
            type: 'script'
        });
        queryMain.condition = queryMain.and(
            queryMain.createCondition({
                fieldId: 'notifyowner',
                operator: <http://query.Operator.IS|query.Operator.IS>,
                values: true
            })
        );
        queryMain.columns = [
            queryMain.createColumn({
                fieldId: 'id',
                alias: 'id'
            })
        ]
        var res = queryMain.run().asMappedResults();
        for (var i in res) {
            var line = res[i];
            var scriptId = line.id;
            try {
                record.submitFields({
                    type: 'script',
                    id: scriptId,
                    values: {
                        'notifyowner': false,
                        'notifyemails': 'your email here'
                    }
                })
            } catch (e) {
                log.debug('skipping id ' + scriptId);
            }
        }
    }
    return exports;
I use this one to turn notify script owner off and set it to a specific email instead, same concept