or I guess as a more general question, how do I `J...
# suitescript
j
or I guess as a more general question, how do I
JOIN
when a field is of type
multiselect
t
tip when creating search, is I'm creating it first in netsuite to check what condition or operator to use.
j
I’m talking about SuiteQL here
schema is not usually the same as Saved Search
s
@jen, there is a mapping table that you have to join to for multi-select fields.
(if you're trying to write the SQL directly)
j
I don’t know how to
JOIN
it though
there’s a field on customer called contactlist which looks like a comma-separated list of the contact ids
but I can’t quite figure out how to
JOIN
using that
s
Are you trying to write a query to run via query.runSuiteQL?
j
yes
s
Try installing the bundle called "SuiteQL Sidekick"
it can show you the SQL behind a workbook easily
j
do you happen to know how to do this JOIN ? I feel it should be something simple
Copy code
SELECT customer.id, customer.name
FROM customer

JOIN ....?

JOIN contact ....?

WHERE contact.id = 1234
I don’t use Workbooks, would that bundle work with saved searches?
s
No, use a workbook to build the join you're trying to do, and then that bundle can tell you the SQL that represents the workbook.
j
ugh, I don’t really use Workbooks. They don’t work at all on most of our data.
I have a query runner for testing concepts. I can view the list of contact ids but can’t seem to join using it
s
CustomerCompanyContact
That's the join table
Here's what it spits out to show entity id and contact name:
SELECT BUILTIN_RESULT.TYPE_STRING(Customer.entityid) AS entityidRAW /*{entityid#RAW}*/, BUILTIN_RESULT.TYPE_STRING(CustomerCompanyContact_SUB.entitytitle) AS contactlistentitytitleRAW /*{contactlist.entitytitle#RAW}*/ FROM Customer, (SELECT CustomerCompanyContact.contactscompany AS contactscompany, Contact.entitytitle AS entitytitle FROM CustomerCompanyContact, Contact WHERE CustomerCompanyContact.contact = Contact."ID" ) CustomerCompanyContact_SUB WHERE Customer."ID" = CustomerCompanyContact_SUB.contactscompany(+)
j
Thanks! I will see if I can modify this for my use case
I would give my left foot for a proper schema diagram
I’m supposed to be “explaining” the database to a non-NetSuite person tomorrow. That should be fun.
s
"Everything is a transaction and an entity"... nothing else to see here 🙂
j
Our most commonly used record is a custom one with like 900 fields.
wish me luck
s
haha
good luck
j
Copy code
SELECT contact.id, contact.firstname, contact.lastname, customer.id, customer.companyname

FROM contact
JOIN customercompanycontact ON contact.id = customercompanycontact.contact
JOIN customer ON customer.id = customercompanycontact.contactscompany

WHERE contact.id = 16357
itworks.jpg
that's the closest I've seen to a diagram, but won't work for suiteql
(See bottom of the page)
j
I use the Schema Browser some
but it’s mostly a guessing game
s
Have you see the database datagrams?
j
nyet
there are diagrams?
s
Scroll to the bottom of that page
you'll find one
j
oh yeah that
s
but that's for connect, not for suiteql
j
yeah
won’t really help anyhow cuz we are soooooo customised
s
I have a feeling a diagram won't help if you have 900 fields!
j
nope