You need to sign in to do that
Don't have an account?
GMASJ
Convert cose block into trigger code
Hi,
I want to add below code inside trigger please help should this is before insert/update or after insert/update
Thanks
GMASJ
I want to add below code inside trigger please help should this is before insert/update or after insert/update
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 = '5002D000004JCQm']) { 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); } } } //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 + '%') order by createddate asc limit 10]; 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
Log is I want to create a trigger on case object which will update its similar records based on the condition only thing is it has to update same object
I have put the logic below inside the trigger it is giving error.
Trigger
Thanks
Sudhir