pitchblack408
pitchblack408

Reputation: 2983

How do I do a mass delete of custom records in NetSuite suitescript 2.0?

My question is really plain. I would like to know if someone has figured out how to mass delete custom records using suitescript2.0.

/** * @NApiVersion 2.x
 * @NScriptType ScheduledScript
 */

define ([         
 'N/error',        
 'N/record',
 'N/runtime',
 'N/log',
 ],
function(error, record,runtime, log) {
    function execute(context) {



    for(var i=4;i< 11614;i++){
    var objRecord = record.delete({ type: 'customrecord_uber_billing_report_data', id: i});

    }


    }
    return {
        execute: execute
    };




});

Eclipse does't seem to like the syntax enter image description here

Upvotes: 1

Views: 4028

Answers (3)

The Programmer
The Programmer

Reputation: 31

You can do that with "promise". Netsuite so far doesn't have a Suitescript function to delete a bunch of records quickly. With this function you can delete one by one, and keep your code working in another thing. Hope this helps.

require(['N/record', 'N/search'], function (record, search) {
    function deleteUnwantedRecords() {
        var objRecord = search.create.promise({
                type: 'customrecord_your_record',
                columns: [
                    'internalid', // The record's ID
                ],
                filters: []// no filters
            }).then(function (result) {
                var HowManyFound = 0;
                result.run().each(function (rl) {
                    HowManyFound++;
                    var recToDelete = rl.getValue('internalId');
                    var objNewRecord = record.delete ({
                            type: 'customrecord_your_record',
                            id: recToDelete,
                        });
                    console.log('Error ID: ' + rl.getValue('internalId'));
                    return true;
                });
                console.log('#Error Logs found: ' + HowManyFound);
            }).catch (function (reason) {
                log.debug("Failed: " + reason);
            })
    }
    var delRecs = deleteUnwantedRecords();
});

Upvotes: 3

pitchblack408
pitchblack408

Reputation: 2983

https://bugs.eclipse.org/bugs/show_bug.cgi?id=443876

Victor Rubezhny 2014-09-11 17:10:24 EDT

As more and more JavaScript libraries and tools become available that are using ECMA5 standard, the using of JSDT becames more and more difficult.

The problem is that ECMA3 that is currently supported by the JSDT Parser doesn't allow many things that are available and enabled to use in ECMA5, for example like using keywords (like abstract, continue, delete, import and so on) as an identifier (a name of property, function or variable).

It's not a trivial task to replace the current JSDT parser/compiler/inference engine with the ones supporting the ECMA5, so the Bug 223131 stays unresolved for many years.

It should be a solution to provide a way to hide such syntax errors for the users that are aware of the limitations of the current JSDT parser, so the users can see their projects free of annoying error markers on included JavaScript Libraries and in their own code.

Comment 1 Victor Rubezhny 2014-09-16 13:26:29 EDT

The patch adds a preference to show/hide syntax errors on keywords The fix adds the new preference to JavaScript->Validator->Errors/Warnings page: "Strict validation of JavaScript keywords usage" (default value is true - in order to make it work in the way it did before). ProblemReporter uses this preference value in order to decide if it has to report syntax errors for keywords or not. The fix includes the editor's reconciler change required to make the preference value change to play immediately after change. ......

Upvotes: -2

erictgrubaugh
erictgrubaugh

Reputation: 8847

You seem to be using record.delete correctly, except that the instances of a single custom record type are not sequential. Not every i from 4 to 11614 will all be instances of customrecord_uber_billing_report_data.

Are you getting any specific errors or behaviour?

Upvotes: 1

Related Questions