RE: How to write script to avoid duplicate record creation before record submit using suitescript 2.0

I want to create a user event script to avoid custom record creation if record is duplicate.

Also this custom record is being attached to another custom record. I have to stop from creating and attaching custom duplicate record.

Please Help!!

Maira S Beginner Asked on February 23, 2023 in SuiteScript.
Add Comment
10 Answers

You need to define your function before you call it.

Declaring it outside of beforeSubmit keeps things nice and neat:

 *@NApiVersion 2.x
 *@NScriptType UserEventScript
define(['N/record', 'N/email', 'N/url', 'N/runtime', 'N/search', 'N/ui/serverWidget'],
function(record, email, url, runtime, search, serverWidget) {
    function CheckDuplicate(){
        var res=[];
        var customrecord_gbs_tax_rule_expt_nexusSearchObj = search.create({
            type: "customrecord_gbs_tax_rule_expt_nexus",
                    search.createColumn({name: "internalid", label: "Internal ID"}),
                    search.createColumn({name: "custrecord_gbs_tren_expt_nexus", label: "Exempt Nexus"})
        var searchResultCount = customrecord_gbs_tax_rule_expt_nexusSearchObj.runPaged().count;
        //log.debug("expensereportSearchObj result count",searchResultCount);
        // alert('Expenses Count: '+searchResultCount);{
            // .run().each has a limit of 4,000 results
            var category=result.getValue({name:"expensedate"});
            var exemptNexus =result.getValue({name:"expensecategory"});
            //if( != recordId){// Exclude the current record
            return true;
        return res;
Intermediate Answered on February 23, 2023.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.