0

I have a map passed as parameter of an apex method. In this method I need to get the values of the map. Here is the apex method :

@AuraEnabled
public static String manageFilters(Map<String, Object> lines){
    System.debug('### lines : ' + lines);
    System.debug('### lines.values() : ' + lines.values());

    for(String key : lines.keySet()){
        System.debug('### lines.get(key) : ' + lines.get(key));
        System.debug('### >>> ' + lines.get(key));

    }

    return null;
}

The map lines is not null and contains some values, here is what I can see in the system debug of lines :

{0={FieldName=AccountId, ObjectName=Opportunity, Operator=<, Value=dfg}}

(Potentially, there could be more than one value)

My question is, how can I get, for example, the value of the 'ObjectName' or the value of the 'FieldName' of this map ?

2

You may use a Map for this:

public static String manageFilters(Map<String, Object> lines){
    System.debug('### lines : ' + lines);
    System.debug('### lines.values() : ' + lines.values());

    for(String key : lines.keySet()){
        System.debug('### lines.get(key) : ' + lines.get(key));
        System.debug('### >>> ' + lines.get(key));
        Map<Object, Object> test = (Map<Object, Object>)lines.get(key);
        System.debug('### test ' + test);
        System.debug('### test ' + test.get('ObjectName'));
    }

    return null;
}
| improve this answer | |

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.