You need to sign in to do that
Don't have an account?
GMASJ
SOQL string search is not returning values
Hi,
I am trying to search based on case subject
Example if different case have subject line as below
1. FW: Case for Testing
2. RW: Case for Testing
3. Case for Testing
I was all the above subject line return when I try to update " FW: Case for Testing"
In below code FW and RW start is getting return not the with out FW or RW.
Thanks
GMASJ
I am trying to search based on case subject
Example if different case have subject line as below
1. FW: Case for Testing
2. RW: Case for Testing
3. Case for Testing
I was all the above subject line return when I try to update " FW: Case for Testing"
In below code FW and RW start is getting return not the with out FW or RW.
String FWSubject; String RWSubject; String CaseSubject; list<case> cselst = new list<case>(); for (Case c : [select id,casenumber,subject,ownerid,owner.name from case where id = '5002D000004JCQr']) { system.debug('Case Number :' + c.casenumber); system.debug('Case Subject : ' + c.subject); system.debug('Case Subject length : ' + c.subject.length()); system.debug('Case Owner Name : ' + c.owner.name); CaseSubject = c.subject; //Search for FW and RW key word were length of the subject is more than 18 //if(c.subject != null && c.subject.length() > 18){ if(c.subject.Contains('FW:')){ FWSubject = c.subject.replaceAll('FW:',''); System.debug('FQ Trim String :' + FWSubject); } if(c.subject.Contains('RW:')){ RWSubject = c.subject.replaceAll('RW:',''); System.debug('RW Trim String :' + RWSubject); // } } } system.debug('FWSubject :' + FWSubject); system.debug('RWSubject :' + RWSubject); //Map<Id, case> c = new Map<Id, case>([select id, casenumber,subject,createddate,ownerid,owner.name from case where CreatedDate = this_year and subject like :('%' + CaseSubject + '%') order by createddate asc limit 10]); //Search for same case based on subject within 10days. list<case> ctendays = [select id, casenumber,subject,createddate,ownerid,owner.name from case where CreatedDate = this_year and ( subject like :('%' + CaseSubject + '%') or subject like :('%' + FWSubject + '%') or subject like :('%' + RWSubject + '%') ) order by createddate asc limit 100]; for(case ctndays : ctendays){ system.debug('Existing Cases :' + ctndays.casenumber + ' ' + ctndays.subject + ' ' + ctndays.createddate + ' ' + ctndays.owner.name); system.debug('Latest Case Owner ' + ctendays[0].owner.name); ctndays.ownerid = ctendays[0].ownerid; ctndays.Duplicate_With__c = ctendays[0].casenumber; cselst.add(ctndays); } //if(cselst.size()>0){ // update cselst; //}
Thanks
GMASJ
for (Case c : [select id,casenumber,subject,ownerid,owner.name from case where id ='5002D000004JCQr'])
your are looping for just 1 record?