Ruby

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...

I just found great the way that the cancel subscription works(ruby pattern) in the braintree gem, that's why I'm sharing this pattern with you guys: Gem https://github.com/braintree/braintree_ruby [ruby] # Just execute this class method Braintree::Subscription.cancel(subscription2.id) [/ruby] Logic Behind the scenes [ruby] # lib/braintree/subscription.rb module Braintree class Subscription def self.cancel(subscription_id) ...

First thing first: Don't forget to setup the environments in my case for example: config/environments/development.rb [ruby] # mailer defaults config.action_mailer.default_url_options = { :host => "localhost:3000" } [/ruby] config/environments/production.rb [ruby] config.action_mailer.default_url_options = { :host => 'elh.mx' } [/ruby] And now let's add the helpers If you are just using the Rails you can do something like: [ruby] module MailersHelper def host_url_for(url_path) root_url.chop + url_path end end [/ruby]

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]