I'm trying to build a bulkified version of Flow's Fast Lookup element so that I can safely trigger bulkified flows from process builder.

I've written an InvocableMethod which allows me to pass in a list of Ids and return a list of SObjects with the appropriate fields queried. These work perfectly with the test class I've written with them, but when invoked from a flow they fail:

public class UserFastLookup {

    @InvocableMethod(label='Retrieve User' description='Returns the User requested, acts as a bulkified version of Fast Lookup')
    public static list<User> getUsers(list<Id> requestIds) {

        //query for user Ids requested
        map<Id,User> recordMap = new map<Id,User>([SELECT Id, Name FROM User WHERE Id IN :requestIds]);

        list<User> userResults = new list<User>();

        //return Users in same order as request to Flow
        for (Id request : requestIds) {

        return userResults;

I've created a very simple flow, which invokes the Apex InvocableMethod with an Id passed into it, captures the User object output into an SObject variable, and dumps it to the screen (as a simplification to the headless flow using a record update, which exhibits the same errors).

<?xml version="1.0" encoding="UTF-8"?>
<Flow xmlns="http://soap.sforce.com/2006/04/metadata">
        <label>Lookup User</label>
    <interviewLabel>User Lookup Test {!$Flow.CurrentDateTime}</interviewLabel>
    <label>User Lookup Test</label>

This fails with the following error:

FLOW_ELEMENT_ERROR The flow failed to access the value for usr.Name because it hasn't been set or assigned.|FlowScreen|Display

If I rewrite the code to return a list of strings it works perfectly (and plugs into process builder and works perfectly for bulk operations, as described here).

public static list<String> getUsers(list<Id> requestIds) {}

I've also attempted to define the SObject within an InvocableVariable for the return type, again no luck

public static list<Result> getUsers(list<Id> requestIds) {}

public class Result {
    @InvocableVariable(label='User' description='Retrieved User Object')
    public User usr;

Can anyone see where I'm going wrong with this, or has anyone successfully passed SObject from an Apex Invocable Method to a Flow?

  • I got the same problem, and the debug log is not helping... Mar 17, 2015 at 10:51
  • Thanks for looking into this. As you say, debug log doesn't add much. I can debug the returned userResults which contains what I'd expect when running the flow. Also invoking the InvocableMethod from the REST API, as described here codeandvogue.com/2015/02/02/el-poder-de-invocable-spring-15, is successful.
    – James
    Mar 19, 2015 at 22:11

1 Answer 1


This was resolved by Salesforce around 3rd May 2015 https://twitter.com/andyinthecloud/status/594895616381165569

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.