Doing an inventory item search when use filter any...
# ask-stanley-ai
s
Doing an inventory item search when use filter anyof on itemid and passing array of strings, getting {"type":"error.SuiteScriptError","name":"UNEXPECTED_ERROR","message":"An unexpected SuiteScript error has occurred"
c
AI generated answer (using internal Slack threads):
Based on the conversations, it seems like you're encountering an error when trying to use the 'anyof' filter on a text field in a SuiteScript search. This is because 'anyof' is not supported for text fields. Instead, you can use the 'is' operator with the 'OR' syntax to filter on multiple values. Here's an example of how you can do this:
Copy code
javascript
[
  ["inventorynumber", "is", "SN1"],
  "OR",
  ["inventorynumber", "is", "SN2"],
]
In this example, 'SN1' and 'SN2' are the inventory numbers you're searching for. You can add more conditions by continuing the pattern with 'OR' and another condition. If you have a variable length array, you might need to write a function to build the filters dynamically. Alternatively, you can use a formula with the 'in' operator. However, this might be slower, especially if you have a large dataset. Here's an example:
Copy code
javascript
[
  "formulanumeric: CASE WHEN {inventorynumber} IN ('SN1', 'SN1') THEN 1 ELSE 0 END",
  "equalto",
  "1",
]
In this example, 'SN1' and 'SN1' are the inventory numbers you're searching for. You can add more values by including them in the parentheses, separated by commas. If you have over 1000 values, you'll need to split them into multiple filters. Remember, using the 'OR' method might be faster the larger the dataset gets, as formulas in criteria can slow the search down. ****** 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.868778825
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.864398956
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.861429811
Please provide your feedback on this answer.