/**
* @NApiVersion 2.x
* @NScriptType Suitelet
* @NModuleScope SameAccount
*/
/**
* Script Description
* This suitelet to search customer.
*/
/*******************************************************************************
*
*
* NetSuite Name :HRP-1 SL Customer Search
* Script ID: customscript_jj_customer_search
*
* *****************************************************************************
*
*
* $Author: Jobin & Jismi IT Services LLP $
*
* DESCRIPTION
* Suitelet to search customer to find the duplicate.
*
* Date Created :16-02-2019
*
* REVISION HISTORY Update:
*
*
*
******************************************************************************/
define(['N/file', 'N/search', 'N/runtime', 'N/record', 'N/https', 'N/encode', 'N/ui/serverWidget', 'N/email'],
function(file, search, runtime, record, https, encode, serverWidget, email) {
var main = {
onRequest: function(context) {
var email = context.request.parameters.email;
var aup_id = context.request.parameters.aup_id;
var filterarray=[];
var customerSearchObj = search.create({
type: "customer",
filters:
[
["email","is",email],
],
columns:
[
search.createColumn({
name: "entityid",
sort: search.Sort.ASC,
label: "Name"
}),
search.createColumn({ name: "email", label: "Email" }),
search.createColumn({ name: "phone", label: "Phone" })
]
});
var found = customerSearchObj.runPaged().count>0?true:false;
if(found)context.response.write("ALREADY_EXISTS");
else context.response.write("ALREADY_NOT_EXISTS");
}
}
for (var key in main) {
if (typeof main[key] === 'function') {
main[key] = trycatch(main[key], key);
}
}
function trycatch(myfunction, key) {
return function() {
try {
return myfunction.apply(this, arguments);
} catch (e) {
log.debug("e in " + key, e);
}
}
};
return main;
});