1

I have a dynamic query which has the where condition like this:

' WHERE (Contract_State__c=\''+'Complete Activated'+'\''+'OR Contract_State__c=\''+'Partially Terminated'+'\''+')'+' AND Original_Term__c = true '+' AND Program__c = NULL '+' AND Originating_Location__c IN: XXX'+' AND ( No_of_Days_to_Expire__c = 30 or No_of_Days_to_Expire__c = 45 or No_of_Days_to_Expire__c = 60 or No_of_Days_to_Expire__c = 90 )'

I have a custom setting called Batch criteria which is of list type. My question is how to add this where query part in the custom setting field. If I copy and paste this, it is not taking the whole part as it is exceeding from 255 characters. How can I do this?

3
  • The basic bodge to get around this length limit is to create multiple 255 character text fields on the custom setting (named e.g. Where1, Where2 etc) and just concatenate the content.
    – Keith C
    Apr 29, 2016 at 12:45
  • Thank you @KeithC . Can you show me the example of how to add the query value to the custom field.
    – Sweta A
    Apr 29, 2016 at 12:48
  • Not exactly sure what you are asking but see answer I just added.
    – Keith C
    Apr 29, 2016 at 12:56

1 Answer 1

1

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;

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .