• #15842
    Salesforce | PRANAV PRANAV #680
    Forcetalks

    How can I dynamically append the fieldtype in SOQL query in Salesforce?

    Hi All,

    How can I dynamically append the fieldtype in SOQL query in Salesforce?

    Thanks

     

    #15845
    Salesforce | Mohit Mohit #435
    Forcetalks

    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

Viewing 2 posts - 1 through 2 (of 2 total)

Please to reply to this topic.

CONTACT US

We're not around right now. But you can send us an email and we'll get back to you, asap.

Sending

About Us

Forcetalks is a Salesforce collaboration platform for coders & developers, geeks & nerds, consultants & business heads, admins & architects, managers & marketers and of course the business owners. A community where you can learn from, where you can contribute to. For you. For Salesforce. Read More...

Copyright 2019 Forcetalks. All Right Reserved.

Log in with your credentials

or    

Forgot your details?