Activity Forums Salesforce® Discussions Dynamic query field values to custom setting fields? Reply To: Dynamic query field values to custom setting fields?

  • Gourav

    Member
    June 2, 2016 at 1:58 pm

    You add the fields to the custom setting through the Setup UI or through other tools. Then you use the "Manage" option to edit the setting. To reference it in code (assuming it is a list custom setting that you need a key for):

    BatchCriteria__c bc = BatchCriteria__c.getInstance(keyValue);

    String whereTerm = '';
    if (!String.isEmpty(bc.Where1__c)) whereTerm += bc.Where1__c;
    if (!String.isEmpty(bc.Where2__c)) whereTerm += bc.Where2__c;
    if (!String.isEmpty(bc.Where3__c)) whereTerm += bc.Where3__c;
    if (!String.isEmpty(bc.Where4__c)) whereTerm += bc.Where4__c;