Hello NetSuite Guru,
I created a button for the sales order form from User Event script, when user clicks on that button, the logic will be processed from a function in the client script attached on that form.
In the function to process the button, I created a search but NetSuite showed the error: Uncaught SyntaxError: illegal character U+200C
Here is the button I created in User event script:
context.form.addButton({
id: "custpage_overwrite_amt_button",
label: "Update amount",
functionName: 'updateAmt('+ recordId + ')'
});
context.form.clientScriptModulePath = "SuiteScripts/CustomerClientScript";
And in the CustomerClientScript.js client script, the updateAmt function creates the search as below:
/**
*@NApiVersion 2.x
*@NScriptType ClientScript
*/
define(['N/error', 'N/record', 'N/https','N/email','N/search', 'N/runtime','N/currentRecord'],
function(error,record,https,email,search, runtime,currentRecord) {
function updateAmt(recordId){
var transRec = record.load({
type: record.Type.SALES_ORDER,
id: recordId,
isDynamic: false
});
var fil1 = search.createFilter({ //-> the error points at this line
name: 'createdfrom',
operator: search.Operator.ANYOF,
values: recordId
});
var fil2 = search.createFilter({
name: 'mainline',
operator: search.Operator.IS,
values: true
});
var col1 = search.createColumn({
name: 'internalid'
});
var col2 = search.createColumn({
name: 'type'
});
var sea = search.create({
type: 'transaction',
filters: [fil1, fil2],
columns: [col1, col2]
});
sea.run().each(function(result){
var internalid = result.id;
var internalid = result.getValue({
name: 'internalid'
});
var recordType = result.getValue({
name: 'type'
});
return true;
})
}
return {
updateAmt: updateAmt
};
)};
So how can we use the 'search' module in the function of a custom button in the client script?
Thank you.