Closed dougq closed 5 years ago
What happens when you look at the address
property of your Quickbooks::Model::EmailAddress
object?
What's the notation for doing that?
Give this a shot:
qb_records = @service.query("Select * from Customer order by id")
qb_records.entries.each do |qb_record|
if qb_record.email_address
puts "The email address is: #{qb_record.email_address.address}"
end
end
I think whats happening is in some cases your Customer records do not have an email address, thus the outer container email_address
itself is non-existent (QB won't return that node if it doesnt exist; its not like it returns but its blank).
So in your case you just need to check if it exists before you attempt to reference it.
Thank you thank you thank you--success! I was obviously looking at the error message WAY too narrowly!
I have the following code
qb_records = @service.query("Select * from Customer order by id")
and cannot figure out how to reference email addresses in the results. I have a loop of the form qb_records.each do |qb_record| and if I try to reference the email address via qb_record.email_address, I get something along the lines of #
If I do qb_record.email_address.inspect, I get something like #<Quickbooks::Model::EmailAddress address: name@gmail.com> (So I can see that there is an email address there.)
But if I do qb_record.email_address.address, I get "undefined method `address' for nil:NilClass"
What code returns the actual email address as a string?
Thanks!