in my mention above, 'x' is one record type, 'a' i...
# suitescript
s
in my mention above, 'x' is one record type, 'a' is another. so for example I'd like to join "salesorder.mycustomkey to somecustomrecord.mycustomkey" which from your response sound like isn't possible
s
two questions: is the record referred to by "mycustomkey" a record type in NetSuite, or does it live in an external database? also, is the relationship between these two records exactly 1:1 (there is one and only one match between the two record types)?
s
the custom key is a primary key from an external database - actually more unique than NS's internal id. This key is stored on multiple NS records types so it to can/should be able to serve as a PK between records, if ad-hoc joins were supported
I think the fact that these linking key values originate from an external database is immaterial, no? The idea is I have a guaranteed unique field on one record type that has a legitimate matching key linking it to another record type. Just like NS has for 'native' joins via internal id - only I seek to do the linking on a custom field that I know is valid as PK/FK between the tables.
s
Yep, I understand this issue exactly. Unfortunately, the only tool that I think can support this is SuiteAnalytics Connect (ODBC, JDBC, or ADO)
But, you could build a custom solution to link these together
The best way, I think, would be to synchronize that primary table into netsuite through some integration (Restlet, Suitelet, or SuiteTalk).
Then, you could store the reference to the NEtSuite internal record type instead. This would be joinable in workbooks, just as you wish.
I have done something like this, and have some record types that simply mirror an external table and a small subset of fields
The other option would be to create a custom linking record type with three fields: the external key, and two List/Record fields referring to the records you want to link. You'd need to create a Map/Reduce or Scheduled script to perform two independent searches, then match the results together, storing them in the linking table. You could then build searches off of that linking table combining values from both records.
If you don't mind using an external tool for queries, I do recommend using the JDBC or ODBC driver. It gives you the ability to write standard SQL queries, joining on any arbitrary fields just as you need to. It really depends upon what you are trying to do.
s
for better or worse, I am familiar with the ODBC side of NS 😕
s
I frequently find myself running a query through ODBC, saving it as a CSV file, then importing into NetSuite to get around the fact that arbitrary field joins are not supported
s
I was hoping that
N/query
in all its shiny newness would give us 'INNER JOIN on table1.col1 = table2.col2'
s
ah, yeah. Sadly it does not, unless there is an actual record type or list to link the two tables with, which is why I asked about that initially.
s
gotcha
s
and even then, it only support joins to/from internal id of netsuite record types. other fields can't be used. so it's better but still very limited.
s
so far, the only 'better' I've seen is the ability to join-to-a-join-to-a-join...
so far, the actual code for doing typical queries is far more complicated looking with
N/query
than the old query filter expression syntax and column specifications in plain
N/search
s
the new syntax is cumbersome. I am not a fan of it.
the fact that you can do parent-child joins or child-parent joins is nice though, meaning you can join two records related to the same record, which definitely was not possible before.
s
aye, I think that's the sole purpose of having both
joinTo
and
joinFrom
. I was hoping I might be able to use them together to create a single ad-hoc join but no dice!
s
i was thinking the same. NetSuite always gets my hopes up, then lets me down