hi, just wondering on how do we query via suiteql ...
# general
i
hi, just wondering on how do we query via suiteql the transactions files? (Transaction > Communication > Files)
r
In SuiteScript, you can use joins like "file" to access related records directly in your search. Unfortunately, in SuiteQL, there's no straightforward equivalent for such joins when it comes to file attachments. The capability to join transactions with their attached files, as done in SuiteScript, isn't directly supported in SuiteQL.
m
@Ryan Valizan I am sure you are well-meaning but posting incorrect ChatGPT responses is not helpful
r
@michoel I apologize for any confusion caused by my initial response. My goal is to provide clear and concise answers quickly and follow up diligently if there's an error. To clarify, SuiteQL doesn't support joins in a way comparable to
N/search
when querying file attachments on transactions. However, I've corrected my approach and here's a tested SuiteScript example that reliably joins transactions with their file attachments using N/search:
Copy code
const tranId = '123456';

const salesOrderSearchObj = search.create({
    type: 'salesorder',
    filters: [
        ['internalid', 'anyof', tranId],
        'AND',
        ['type', 'anyof', 'SalesOrd'],
        'AND',
        ['mainline', 'is', 'T'],
    ],
    columns: [
        search.createColumn({
            name: 'internalid',
            join: 'file',
            label: 'Internal ID',
        }),
        search.createColumn({
            name: 'name',
            join: 'file',
            label: 'Name',
        }),
        search.createColumn({ name: 'tranid', label: 'Document Number' }),
    ],
});
const searchResultCount = salesOrderSearchObj.runPaged().count;
log.debug('salesOrderSearchObj result count', searchResultCount);
salesOrderSearchObj.run().each(function (result) {
    return true;
});
For those who prefer generative tools from NetSuite UI, I also recommend these browser extensions for an easier export experience from within NetSuite: • NetSuite: Dataset/Workbook ExportNetSuite: Search Export