Looking for proper query to join address city stat...
# general
e
Looking for proper query to join address city state zip to customer. I am trying to just simply join the full address,city,state zip to the customer in SuiteQL. I have working sample up to the customer, customeraddressbook. But getting the actual city state zip etc.. I'm not sure of the schema and join rules.. I get an error Search error occurred: Record ‘address’ was not found... Probably not the correct table name. I've been Using MartyZigmans NetSuite SQL Query Tool to test queries. I am successfully using Restlets and suiteql but am stymied by the join of address.
t
@Eric Johnson This might help.
Copy code
SELECT
	Customer.EntityID AS ID,
	Customer.CompanyName AS Name,
	Customer.CreditLimit,
	Customer.OnCreditHold,
	BUILTIN.DF( Customer.Terms ) AS PaymentTerms,
	BUILTIN.DF( Customer.SalesRep ) AS SalesRep,
	Customer.BalanceSearch AS BalanceTotal,
	Customer.OverdueBalanceSearch AS BalancePastDue,
	BillToAddress.Addressee AS BillToAddressee,
	BillToAddress.Addr1 As BillToAddress1,
	BillToAddress.Addr2 As BillToAddress2,
	BillToAddress.Addr3 As BillToAddress3,
	BillToAddress.City As BillToCity,
	BillToAddress.State As BillToState,
	BillToAddress.Zip As BillToZip,
	BillToAddress.Country As BillToCountry,
	BillToAddress.Attention As BillToAttention
FROM
	Customer
	LEFT OUTER JOIN EntityAddressbook AS DefaultBilling ON
		( DefaultBilling.Entity = Customer.ID )
		AND ( DefaultBilling.defaultbilling = 'T' )
	LEFT OUTER JOIN EntityAddress AS BillToAddress ON
		( BillToAddress.nkey = DefaultBilling.AddressBookAddress )
WHERE
	( Customer.IsInactive = 'F' )
	AND ( Customer.OverdueBalanceSearch > 0 )
ORDER BY
	Customer.EntityID
There's more info here: https://timdietrich.me/blog/netsuite-suiteql-customer-accounts-receivable-queries/
Also, we do have a #C01FBBZ8PQC channel. You might be able to get more help over there.
Hope this helps!
e
This is solved through use of customeraddressbookentityaddress select b.addressbookaddress, bb.*, b.internalid, b.entity c.id CustomerID, c.entityid as EntityID, c.companyName as CompanyName from customer c left outer join customeraddressbook b on (b.entity = c.entityid) left outer join customeraddressbookentityaddress bb on b.addressbookaddress=bb.nkey order by companyname
Found it finally using Analytics browser. On the browsers Sort by ID is better to look through than Sort by Label. fyi