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?

can we change the ownerID field and if yes How ?

Set the ownedBy property on the Compose Record variable; here is an example (do note that this screenshot is on the 2022.3.0-dev.1 version; it is the same for 2021.9)