function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Mike Bucci 6Mike Bucci 6 

I have a flow that is kicking out a "Bind variables only allowed in Apex code" error. Does anyone understand what could be causing this?

I hae a flow that is returning this error after a pause.  Can you help me understand why this would be occuring?

Error Occurred: This error occurred when the flow tried to look up records: Questionnaire_Number_of_Returns__c, Owner:User FROM Lead WHERE ((Id = '00Q1800000Bmhk1EAB')) ^ ERROR at Row:1:Column:52 unexpected token: ':' (Bind variables only allowed in Apex code).
Agustin BAgustin B
Hi Mike, this seems to be that you are using a query with =: which means you are binding variables and that is only for apex use.
On other places just use = withouth the :

if it solves your issue, please mark this answer as correct, it may help others.
Good luck.
Mike Bucci 6Mike Bucci 6
Agustin, this is being generated from a flow so I am unclear on how what you are saying can occur.
SwethaSwetha (Salesforce Developers) 
HI Mike,
This appears to be syntax issue. Can you share a screenshot of your flow at the pause where it is throwing an error?

Related issues:
https://salesforce.stackexchange.com/questions/32451/bind-variables-only-allowed-in-apex-code

https://salesforce.stackexchange.com/questions/165029/bind-variables-only-allowed-in-apex-code-when-comparing-fields-from-two-differ

https://salesforce.stackexchange.com/questions/262391/getting-bind-variables-only-allowed-in-apex-code-when-attempting-this-query

Thanks
Jeremy HendyJeremy Hendy
It looks like it's an issue with the Lead object in Flow.  The Lead record has "Owner (User)" and "Owner (Group)" related objects; if you pick "Owner (User)" from the flow definition, this appears to get implemented as "owner:user" in the underlying query, which then fails at runtime.  

The solution is to use the field "OwnerID" which is a text field within the body of the Lead, instead of trying to navigate to Lead->Owner (User)->ID