Syntax error: missing ; before statement

When I upload the following code I get the error “Syntax error: missing ; before statement”

 

/**
 * @NApiVersion 2.x
 * @NScriptType UserEventScript
 */
define([‘N/record’, ‘N/log’, ‘N/search’ ], function(record, log) {
    function beforeLoad(context) {
        //Log our enteties
        if(context.type === context.UserEventType.VIEW){
            var fulfillmentRecordID = context.newRecord.id;
            log.debug(“Fulfillment Id”,fulfillmentRecordID);
            const inventoryDetailSearchFilters: SavedSearchFilters = [
                [‘pickcarton’, ‘isnotempty’, ”],
                ‘AND’,
                [‘transaction.internalid’, ‘anyof’, ‘6327795’],
            ];
            const inventoryDetailSearchColPickCarton = search.createColumn({ name: ‘pickcarton’ });
            const inventoryDetailSearch = search.create({
                type: ‘inventorydetail’,
                filters: inventoryDetailSearchFilters,
                columns: [
                    inventoryDetailSearchColPickCarton,
                ],
            });
            log.debug(inventoryDetailSearch);
        }
    };
    return {
        beforeLoad: beforeLoad
    };
});

 

I am trying to build a saved search to pull the carton field from the Item Fulfillment Record’s Line Item Inventory Detail. I then will be taking the list of cartons and making the unique values and putting them in a field in the Header.

Rookie Asked on December 27, 2023 in SuiteScript.
Add Comment
2 Answer(s)

I strongly suspect the use of const requires SuiteScript 2.1 – just change 2.x to 2.1 at the top of the script.

Intermediate Answered on December 27, 2023.
Add Comment

Try

/**
* @NApiVersion 2.x
* @NScriptType UserEventScript
*/
define([‘N/record’, ‘N/log’, ‘N/search’], function(record, log, search) {
function beforeLoad(context) {
// Log our entities
if(context.type === context.UserEventType.VIEW){

var fulfillmentRecordID = context.newRecord.id;
log.debug(“Fulfillment Id”, fulfillmentRecordID);
var inventoryDetailSearchFilters = [
[‘pickcarton’, ‘isnotempty’, ”],
‘AND’,
[‘transaction.internalid’, ‘anyof’, ‘6327795’]
];

var inventoryDetailSearchColPickCarton = search.createColumn({ name: ‘pickcarton’ });

var inventoryDetailSearch = search.create({
type: ‘inventorydetail’,
filters: inventoryDetailSearchFilters,
columns: [
inventoryDetailSearchColPickCarton,
],
});

log.debug(“Inventory Detail Search”, inventoryDetailSearch);
}
};
return {
beforeLoad: beforeLoad
};
});

Beginner Answered on December 27, 2023.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   Become a Sponsor   Become a Sponsor