I have a search that is searching previous sales o...
# suitescript
p
I have a search that is searching previous sales order and if it finds an order with the same value as the custom field that was changed it will show an alert. This works fine except if there are multiple results it is showing 1 alert per result. How can I have it show all of the results in the alert and separate the results with a comma?
Copy code
var s = search.create({
        type: search.Type.TRANSACTION,
        filters: [
        ["custbody_origin_so","anyof",originSO], 
          "AND", 
        ["type","anyof","SalesOrd"], 
          "AND", 
        ["mainline","is","T"],
        ], 
        columns: [
            search.createColumn({name: "tranid"}),
        ]
    });
    
    var pagedData = s.runPaged({pa​g​e​S​i​z​e : 1000});
    
    // iterate the pages
    for( var i=0; i < pagedData.pageRanges.length; i++ ) {

        // fetch the current page data
        var currentPage = pagedData.fetch(i);

        // and forEach() thru all results
        currentPage.data.forEach( function(result) {

            // you have the result row. use it like this....
            var previousBK = result.getValue('tranid'); 
        alert('The origin sales order number you have entered has already been used in ' + previousBK +'. Make sure you are not creating a duplicate record before saving this order.');
        });

    }