I have a Record Type called VIP Zip Code the " Name" of each record is zip and contains a zip code
| Description | ID | Type | Include In List |
|---|
| CIty | custrecord_vip_zipcode_cit | Free-Form Text | Yes |
| Area | custrecord_vip_zipcode_are | List/Record (VIP Zip Code Areas) | Yes |
| County | custrecord_zipcode_county | Free-Form Text | No |
| Delivery Charge Per Item ($) | custrecord_vip_delivery_charge_per_item | Free-Form Text | Yes |
| Delivery Surcharge ($) | custrecord_vip_delivery_surcharge | Free-Form Text | Yes |
Opportunity Location Routing | custrecord_opp_location_routing | List/Record (Location) | Yes |
I created a function in the javascript for an Email Plug-In Implementation.
The plugin has been working for about a year. The code I added for the latest email that is coming in works and creates a Lead, then an Opportunity, the lead properly changes to a Prospect.
I use this function to try and take the zip code(name) and return custrecord_opp_location_routing. (Stores Location Name/Id)
The plugin is running under a Custom Administrator role that has full permissions on the Record and the Vip Zip Code Area Custom Record Type and the native Location List.
A saved search works under the Custom Administrator role(saved search code) and returns the correct store
var searchresults = nlapiSearchRecord("customrecord_vip_zipcode",null,
[
["name","is",zip],
"AND",
["isinactive","is","F"]
],
[
new nlobjSearchColumn("custrecord_opp_location_routing")
]
);
Below is the library function I use in the email plugin and a restlet. It works properly in the restlet returning the store name/id.
In the plugin code can see the zip coming in, but an empty searchresults string is returned by the search, the function then returns false to the call.
function SetStoreLoc(zip,getText){
// returns the Store for zip
// getText == true returns Store Name
// getText == false or ommitted returns Store Id
!getText ? getText = false : getText;
nlapiLogExecution('debug', '4762 Zip Code ', zip);
if (zip) {
var filters = [];
var columns = [];
filters.push(new nlobjSearchFilter('name', null, 'is', zip));
filters.push(new nlobjSearchFilter('isinactive', null, 'is', 'F'));
columns.push(new nlobjSearchColumn('custrecord_opp_location_routing'));
var searchresults = nlapiSearchRecord('customrecord_vip_zipcode', null, filters, columns);
if (searchresults) {
if (getText == true) {
return searchresults[0].getText('custrecord_opp_location_routing');
}
else {
return searchresults[0].getValue('custrecord_opp_location_routing');
}
}
}
return false;
I replaced the code for the search with the one exported from the saved search and got the same result in the plugin, but the restlet still worked.
Any idea why this search is failing in the email plugin? Any help would be appreciated.