Check out Oracle NetSuite upcoming events and conferences here
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!
Update your Profile with your Support type to get your Support Type badge.
Expand your NetSuite knowledge by joining our Ask A Guru Live sessions. RSVP on this event now.
Community Poll: What sort of content would you like to see more of?

Error adding formula to search

edited Dec 2, 2019 5:58PM in SuiteCloud / Customization 4 comments

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 );

Howdy, Stranger!

Log In

To view full details, sign in.


Don't have an account? Click here to get started!


Community Whiz

Quarter 1 (Jan-Mar 2024)

This Week's Leaders

This Month's Leaders

All Time Leaders