Discussions
Stay up-to-date with the latest news from NetSuite. You’ll be in the know about how to connect with peers and take your business to new heights at our virtual, in-person, on demand events, and much more.
Now is the time to ask your NetSuite-savvy friends and colleagues to join the NetSuite Support Community! Refer now! Click here to watch and learn more!
New AI Community Guidelines. Please review and follow them to ensure AI use stays safe, accurate, and compliant.
Stay in the Know
Be sure you're subscribed to NetSuite communication to stay in the know about monthly happenings, updates and announcements. Subscribe
Be sure you're subscribed to NetSuite communication to stay in the know about monthly happenings, updates and announcements. Subscribe
Error adding formula to search
I'm trying to write a custom search based on the great-circle algorithm to find clients within y miles of x address. I have added two custom fields to the customer record, custentity_gclat and custentity_gclng. When I try running the following script in the debugger I get a FORMULA_ERROR.
var address = { 'lat' : 40.561598, 'lng' : -111.96088 }; var distance = 10; var filters = [ new nlobjSearchFilter( 'formulanumeric', null, 'lessthan', distance ) ]; // todo - to switch from miles to km, change 3956 to 6367(or 6371?) filters[0].setFormula( "3956 * 2 * ASIN( SQRT( POWER( SIN( ((({custentity_gclat}-("+address['lat']+"))*0.01745329252)/2) ), 2 ) + COS( "+address['lat']+"*0.01745329252 ) * COS( {custentity_gclat}*0.01745329252 ) * POWER( SIN( ((({custentity_gclng}-("+address['lng']+"))*0.01745329252)/2) ), 2 ) ) )" ); var columns = []; var searchresults = nlapiSearchRecord( 'customer', null, filters, columns );
Tagged:
0