Rails

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]

[ruby] validates_format_of :url, :with => /\A(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w\.-]*)*\/?\Z/i [/ruby] Notice that I'm using "A" and "Z" because if you use ^ and $ you will see this warning security from Rails validators. [ruby] Valid ones: 'www.crowdint.com' 'crowdint.com' 'http://crowdint.com' 'http://www.crowdint.com' Invalid ones: 'http://www.crowdint. com' 'http://fake' 'http:fake' [/ruby] ...

How to create a new nested attribute form for only new records in a has_many relationship using simple_form, well according to this stackoverflow http://stackoverflow.com/questions/14884704/how-to-get-rails-build-and-fields-for-to-create-only-a-new-record-and-not-includ I was trying to create a new records using nested attributes the problem with that solution it is that if the...

Hello Guys, In this post I'm going to start putting all about queries in rails, so if you find any interesting query let me know and I can put it here, so let's get right to it: Something that I found really useful to understand how the joins works is using this image: If you want to retrieve all the orders that contain more than 2 shipments (Using Spree models) [rails] # this is using inner joins buy default from rails Spree::Order.joins(:shipments).group("spree_shipments.order_id").having("count(spree_shipments.id) > 2") [/rails]

Actually it is pretty straightforward you just have to download and use ngrok(it's free): [program] https://ngrok.com/ [/program] In my case I'm using a rails application so I just need to: [shell] # run my server in localhost rails server # at this moment it is available in http://localhost:3000 by default # if you want...

First thing you have to do is log-in to your server using ssh and going to the discourse installation path: [shell] # login in to your ssh account ssh youraccount@yourip.com cd /var/discourse [/shell] If you need to see the rails logs and see what is doing discourse the commands bellow are what you're looking for: [shell] # connecting to the rails application ./launcher ssh app cd /var/www/discourse #starts all the logs in console tail -f log/*.log [/shell]