Activity Forums Salesforce® Discussions How can I dynamically append the fieldtype in SOQL query in Salesforce?

  • Mohit

    Member
    September 7, 2016 at 5:46 am

    Hi Pranav,

    You can give the dynamic fieldtype in SOQL  in this way:-

    String type ='fieldtype';
    String test = String.valueof(testvalue); // the value on which you want to perform search action.
    sObject obj = Database.query('SELECT Id,name FROM sObject WHERE ' + type + ' like \'%' + test + '%\' limit 1');
    System.debug('@@@'+obj);

    I hope you get your answer

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos