Hi All. I'm looking for some help/information on a...
# suitescript
j
Hi All. I'm looking for some help/information on accessing custom records via a client script. I see how i can load one record by providing the "id" of the record i want to load. Is there a way to specify a qualifier (like a sql where clause) when i load a custom record. Also, is there a way to loop through multiple records, or is this a case for SuiteQL? Basically, I'm writing some reconcilliation scripts and want to load an invoice into a custom record and then access it. Any pointers would be appreciated!
b
Did you try to use search record?
nlapiSearchRecord?
j
no i didn't. I'm currently accessing the record with this call. How would i use the search call in SS 2.x? var newVendorInvoiceRecord = record.load({ type: 'customrecord_vendor_invoice', id: 2, isDynamic: true });
b
search.create
load search module
j
@Borys Peten ah.... I see. I've never worked with custom records in SS before, so i wasn't sure how to access them. That should provide all the functionality i need. Thanks!
b
np
s
depending on your usecase, i want to highlight a usecase that in cases where it's a client script you might want to consider submitting a suitelet to handle things server-side to make it more secure, and "role friendly" , in this way you can supply the ids as params and have the suitelets return the search results, this will mean you can remove other criterias in your CS and hide your logic (if it's what you need of course)
j
@Sciuridae54696d interesting, thanks, i'll keep this in mind
Can someone help me with the syntax? I have a custom record, name = "Invoice List", rectype/internalId=293. I have tried to create a search inserting multiple values for type, but non seem to work. below is one example: var s = search.create({ type: "customrecord_293", columns: ["custrecord_item_name","custrecord_amount"] })
r
Hi JR, Please check the search.create sample code snippet in the NetSuite Help var mySalesOrderSearch = search.create({ type: search.Type.SALES_ORDER, title: 'My Second SalesOrder Search', id: 'customsearch_my_second_so_search', columns: [{ name: 'entity' }, { name: 'subsidiary' }, { name: 'name' }, { name: 'currency' }], filters: [{ name: 'mainline', operator: 'is', values: ['T'] }], settings: [{ name: 'consolidationtype', value: 'AVERAGE' }] }); So your custom record search and traverse would look like this : var customRecSrch = search.create({ type: "customrecord_293", filters: [ ["isinactive","is","F"], "AND", ["mainline","is","T"], ], columns: [ {name: "entity"}, {name: "subsidiary"}, {name: "name"}, {name: "currency"}, ] }); customRecSrch.run().each(function(result) { result.getValue({name: "entity"}); result.getValue({name: "subsidiary"}); result.getValue({name: "name"}); result.getValue({name: "currency"}); return true; }); Hope this helps. Thanks
b
internal id of the custom record is irrelevant
use the id (internal id is scriptid) from the custom record type
b
type is wrong
j
Thanks for everyones input. I used the following to query my custom record: var s = search.create({ type: "customrecord_vendor_invoice", filters: ["custrecord_item_name", "is", mySublistItem], columns: ["custrecord_item_name", "custrecord_shipped_quantity", "custrecord_unit_price", "custrecord_amount"] })