Hi, I'm trying to use n/Record to access the "cont...
# suitescript
a
Hi, I'm trying to use n/Record to access the "contacts" sublist of a sales order, but it's only returning an empty array. The sales order itself has 5 contacts on it. The same code works just fine for the items sublist, but contacts seems to be inaccessible. Any tips?
a
I'm not in a NS account right now, but I don't think there is a native "contacts" sublist on the sales order record? I think you'd have to load the customer record and get the contacts from that
a
It’s a native sublist (99% sure). The contacts there are potentially separate from the customer contacts, so I can’t query the customer to get the same configuration. It is odd the record browser doesn’t have that shown, but it’s in the relationships sub tab of the sales order and the sublist name is contacts.
b
you will want to be able to recognize the 4 basic sublist types, they actually act differently in suitescript and have different levels of support
sadly the best documentation on the subject is contained within the suitescript 1.0 docs, starting on page 171
j
@amoreng I’ve encountered this same limitation. It shows up under record.getSublists but it’s empty
a
@battk interesting. It seems using 1.0 I still cannot access that contacts list directly from the sales order record. It appears from the link above this would qualify as an "editor" type sublist. I wonder if there is a way to query the record somehow to get the contacts, but I suppose worst case I can initialize the new sales order records with the contacts of the customer into a custom field and then the user can edit that from there
b
suitescript 1 isnt any more useful than suitescript 2 for working with sublists, they support the same types
its useful since its documentation gives a better description of the different sublist types
a
In the documentation line 183 it states: In some cases you can use search joins in SuiteScript to search the data on a static list sublist (for example, data related to notes, contacts, messages, or files that appear on a particular record). In the previous example, you could use the file search join to search for all files associated with this particular Customer record. I wonder if that is indeed possible, but I cannot find an example of it
b
as in you want help using the file join in a customer search?
a
no, meaning in their text they seem to suggest it is possible to perform a search on a static sublist via a join from the record to the sublist (sales order to contacts, in this case) but it doesn't appear to be possible when I try that out.
b
it depends on the record, they have different joins exposed
a
There's got to be some table storing the relationship between the sales order and the contacts, but records catalog doesn't indicate a relationship between those nor does there appear to be a table that obviously stores it. crazy this is not more straightforward!
b
for your record, you can access files in a transaction search, but not contacts in general
👍 1
searches (and queries) are all different views for the underlying database, they dont expose every relationship, only the ones they cared to support
a
It's wild to me that they don't support the reading (via code) of the sales order contacts. Thank you for your help and dialog!
b
you misidentified the sublist type earler, it most certainly is not an editor type subblist, in fact, the only way you will ever see one of those is in a suitelet
a
you're right, my mistake.
Quick update; this search is possible by going from the Contact to then the Transaction: Internal ID. Passing in the internal ID of the transaction (in this case my SO) will return the contacts on that SO