Thanks for reaching out to Microsoft Q&A.
The issue you're facing is related to how SOQL handles strings used in the IN
clause. Here's why the SOQL query doesn't accept your variable and how to fix it:
1. Problem:
- SOQL expects individual values separated by commas within the
IN
clause, not a single string containing multiple comma-separated values.
2. Solution:
There are two ways to address this:
A. Split the string into individual values and use a loop:
- Split the string into an array: Use a function like
split()
in your programming language (e.g., Python:data.split(",")
) to split the string variable containing comma-separated IDs into an array of individual IDs. - Loop through the array: Iterate through the array using a loop (e.g.,
for
loop) and build your SOQL query by adding each ID within single quotes and separated by commas within parenthesis in theIN
clause.
Example (assuming your programming language is Python):
data = "ID1, ID2, ID3" # Your comma-separated string
# Split the string into an array
id_list = data.split(",")
# Build the SOQL query with a loop
soql_query = f"SELECT * FROM ObjectName WHERE Id IN ('{','.join(id_list)}')"
# Execute the SOQL query with your desired logic
B. Use string manipulation to build the SOQL query directly:
- Remove unnecessary quotes when writing the dataflow output to the variable. This ensures the string remains a plain comma-separated list.
- Directly build the
IN
clause within the SOQL query string by concatenating the single quotes around each ID joined by commas and enclosed in parenthesis.
Example:
soql_query = f"SELECT * FROM ObjectName WHERE Id IN ({data})"
Note: In both approaches, make sure you have proper error handling to catch potential issues during the process.The issue you're facing is related to how SOQL handles strings used in the IN
clause. Here's why the SOQL query doesn't accept your variable and how to fix it:
if the issue persists please provide more information and screen shots if possible.
Hope this helps. Do let us know if you any further queries.