• Vishal Tiwari 36
  • NEWBIE
  • 10 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 1
    Replies
Hi All, 

I'm trying to query a field on Object__c which stores information like (1001|01).

Example:
 
String str = '\'1001|01\'';
List<Object__c> recordList = [SELECT ID FROM Object__c WHERE Field__c includes (str) LIMIT 50000];

Exception Message is shown as below:
 
"common.apex.runtime.impl.ExecutionException: expecting a right parentheses, found '&#124;'"


Below are the list of things I have already tried to stop pipe symbol from getting converted into it's Unicode:

1. unescapeHtml4()
System.debug(str.unescapeHtml4());

2. EncodingUtils.urlDecode();
String str = '\'1001%7C01\''; // %7C is equivalent to pipe (|) symbol
System.debug(EncodingUtil.urlDecode(str, 'UTF-8'));


3. replace() and replaceAll() methods to convert &#124; to pipe symbol dynamically
All the above ways failed to get the required results.

Any other help or direction would be appreciated.

Thank you
I have a class something like this:

global void execute(Database.BatchableContext BC, List<OBJ__c> objList) {
        try{
            if(objList!= null && objList.size() > 0 ){
                delete objList;
            }
        }
        catch(Exception ex){
            System.debug('Exception');
        }
    }

My test class:

 List<OBJ__C> cartList = [SELECT id from OBJ__C LIMIT 1]; 
        Test.startTest();
        BATCH_CLASS deleteCartBatch = new BATCH_CLASS ();
        Database.executeBatch(deleteCartBatch, 200); 
        Test.stopTest();


How do I cover the catch block in this test class?

 
 global void execute(Database.BatchableContext BC, List<OBJ__c> objList) {
        try{
            if(objList!= null && objList.size() > 0 ){
                delete objList;
            }
        }
        catch(Exception ex){
            System.debug('Exception');
        }
    }
I have a custom label in CSV format called Test having value abc, xyz and I want to create a string in the form 'abc','xyz'. How would we do that?

String str = System.Label.Test;
 
 global void execute(Database.BatchableContext BC, List<OBJ__c> objList) {
        try{
            if(objList!= null && objList.size() > 0 ){
                delete objList;
            }
        }
        catch(Exception ex){
            System.debug('Exception');
        }
    }