Activity Forums Salesforce® Discussions Can we use Map in dynamic query?

  • Abhinav

    Member
    April 29, 2016 at 2:24 pm

    Yes, you can please refer here :- http://salesforce.stackexchange.com/questions/117746/why-i-can-not-use-map-in-dynamic-query/117951#117951

  • Suyash

    Member
    April 30, 2016 at 7:49 am

    Hi Piyush,

    You cannot directly use mapname.keyset() or mapname.values() in dynamic queries as dynamic query doesnt allow to map methods to be used in it.
    For this you need to fill all the keys or values in a set or list and then IN check to query filterd  data
    For ex.
    set<string> mapkeys=new set<string>()

    mapkeys.addAll(mapname.keyset());

    string query='Select id from lead where fieldName IN:mapkeys'

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos