I need help here please. *select * from contact...
# ask-stanley-ai
b
I need help here please. *select * from contact fetch first 2 rows only actually fetched the contacts* *but when I did -- select * from contact where subsidiary = 2 fetch first 2 rows only* I got nothing How do I filter by subsidiary? (edite
c
AI generated answer (using internal Slack threads):
It seems like you're trying to filter contacts by subsidiary using SuiteQL. The issue you're facing might be due to the fact that the 'subsidiary' field in the 'contact' table might not be directly comparable to an integer value. In NetSuite, subsidiaries are usually referenced by their internal ID, which is a unique identifier for each subsidiary. However, in the 'contact' table, the 'subsidiary' field might be storing a reference to the subsidiary record, not the internal ID of the subsidiary. You can try joining the 'subsidiary' table in your query to get the internal ID of the subsidiary and then filter based on that. Here's an example of how you might do this:
Copy code
sql
SELECT * 
FROM contact 
JOIN subsidiary ON contact.subsidiary = subsidiary.id 
WHERE subsidiary.id = 2 
FETCH FIRST 2 ROWS ONLY
Please replace 'id' with the actual field name for the internal ID in the 'subsidiary' table. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.818743646
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.808576107
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.80182147
Please provide your feedback on this answer.
b
I want to list products by subsidiary, what is wrong with this code ../* * Lists all products from NetSuite * * Returns id, itemid, displayname, salesdescription, and baseprice from products in your NetSuite account. */ .arguments // Optionally how many rows to maximumly return. Defaults to 25 unless specified. limit:long // Optional ID of product from where to start returning rows. Defaults to nothing. from:string // Optional filtering argument the displayname must match. For instance 'xyz' here will match products with displaynames of 'xyz_1' and 'entity-2-xyz_2'. filter:string // Mandatory argument for subsidiary ID to retrieve products for. subsidiaryid:long // Making sure workflow is discoverable as such from machine learning component. .type:public // Sanity checking invocation. validators.mandatory@.arguments/*/subsidiaryid // Checking if caller supplied -1 as limit or if limit exceeds 25. if or and exists@.arguments/*/limit not-null@.arguments/*/limit eq convert@.arguments/*/limit type:long .long-1 mt convert@.arguments/*/limit type:long .long25 .lambda // Defaulting limit to 25 to avoid returning too many records. set-value@.arguments/*/limit .long25 add../*/return-nodes . warning:We can only retrieve a maximum of 25 products at the same time, ask for more products to see more products. // Dynamically creating our query. .q set-value@.q strings.concat .:@"select i.id, i.itemid, i.displayname, i.salesdescription as description, i.baseprice from inventoryitem i where i.subsidiary = " get-value@.arguments/*/subsidiaryid .:"" // Checking if we're doing paging. if exists@.arguments/*/from .lambda set-value@.q strings.concat get-value@.q .:" and i.id > " get-value@.arguments/*/from // Checking if we're doing filtering. if exists@.arguments/*/filter .lambda set-value@.q strings.concat get-value@.q .:" and upper(i.displayname) like upper('%" get-value@.arguments/*/filter .:"%')" // Adding limit. set-value@.q strings.concat get-value@.q .:" order by i.id fetch first " get-first-value get-value@.arguments/*/limit .long25 .:" rows only" // Logging the generated query for debugging. log.info@.q // Forwarding heavy lifting to core file. execute-file:/modules/netsuite/workflows/workflows/netsuite-query.hl q@.q // Returning result to caller. add../*/return-nodes get-nodes@execute-file/* return-nodes