How to search Compose records by OwnerID from a workflow

How to use compose record search query by ownedBy?

I am using an expression below to as query expression where “record.ownedBy” is passed from the initial trigger. Although this works from the api but it does not work in the workflow, I always get total as 0 .

“ownedBy=” + record.ownedBy

Seems like a permission issue. This is wierd because the record can be accessed from api and from the ui but not from workflow untill the permission is set to read for everyone.

Have you set the Run as option when you defined the workflow?

Yes I did, the user was an administrator with all the permission assigned by default.

\cc @darh can you have a quick read through the code if we’ve messed up the security context somewhere?