netsuite

Hey guys how's it going?

Why Netsuite does not publish the available operators for searching and makes our lives easier? well I don't know but today I'm going to share with you how to search custom records by a custom field within Netsuite in my case for instance: I want to search all the Sales order that have an empty custom field you know a custom field is not a default field within the Netsuite Schema and my custom field is called: 'custbody_order_number', so based in that this is the code I have created: Btw I'm using for that this gem: https://github.com/NetSweet/netsuite

Searching all type of sale orders records that do not have a empty custom field

[ruby] def search_empty_sales_order_number [ { field: 'customFieldList', value: [{ field: 'custbody_order_number', type: 'SearchStringCustomField', operator: 'empty' }] } ] end search_result = NetSuite::Records::SalesOrder.search( criteria: { basic: search_empty_sales_order_number } ) search_result.results [/ruby]

searching only "salesOrder" types  that do not have a empty custom field

[ruby] def search_empty_sales_order_number [ { field: 'customFieldList', value: [{ field: 'custbody_order_number', type: 'SearchStringCustomField', operator: 'empty' }] }, { field: 'type', operator: 'anyOf', type: 'SearchEnumMultiSelectField', value: ['_salesOrder'] } ] end search_result = NetSuite::Records::SalesOrder.search( criteria: { basic: search_empty_sales_order_number } ) [/ruby] Searching by multiple custom fields [ruby] def search_empty_tracking_link_fullfilments [ { field: 'customFieldList', value: [{ field: 'custom_tracking_number', type: 'SearchStringCustomField', operator: 'notEmpty' }, { field: 'custom_transaction_id', type: 'SearchStringCustomField', operator: 'empty' } ] }, { field: 'type', operator: 'anyOf', type: 'SearchEnumMultiSelectField', value: ['_itemFulfillment'] } ] end search_result = NetSuite::Records::ItemFulfillment.search( criteria: { basic: search_empty_tracking_link_fullfilments } ) search_result.results [/ruby]

I was struggling with the "UNEXPECTED_ERROR, An unexpected error occurred. Error ID" error received while using the Netsuite Webservice endpoints. The error looked something like so: [shell] <soapenv:Body> <addResponse xmlns="urn:messages_2014_2.platform.webservices.netsuite.com"> <writeResponse> <platformCore:status xmlns:platformCore="urn:core_2014_2.platform.webservices.netsuite.com"...