You need to sign in to do that
Don't have an account?
Soundar Rajan Ponpandi
Not Able To Update in Trigger (After Insert)
HI,
I can't get the CaseID from Case activity based on the condition. Can Anyone please check and let me know how can i solve this problem.
Trigger
Thanks In Advance.
Soundar.
I can't get the CaseID from Case activity based on the condition. Can Anyone please check and let me know how can i solve this problem.
Trigger
/* Name : BusinesStatusAndStatusUpdate Description : Update Receive Document , Receive & Track Credit Balance, Contact Provider, Confirm Credit Balance,Verify Provider Billing Issues And Create a New Case Created By : OrbitTeam_Soundar Created Date : 08/11/2017 */ trigger BusinesStatusAndStatusUpdate on Case_Activity__c (After Update) { Set<Id> caseId = New Set<Id>(); List<Case_Activity__c> casActList = New List<Case_Activity__c>(); List<Case_Activity__c> Up_casActList = New List<Case_Activity__c>(); //For Getting a record Type Id creditbalreportId = Schema.SObjectType.Case_Activity__c.getRecordTypeInfosByName().get('Receive And Track Credit Balance').getRecordTypeId(); System.debug('Credit Balance Report recordType name |' + creditbalreportId ); string ownerId =''; For(Case_Activity__c ca : Trigger.New){ system.debug('Checking for CaseId '); If(ca.Case__c != Null && ca.RecordtypeId == creditbalreportId && ca.Activity_Business_Status__c == 'Credit Balance Reported' && ca.Case__r.Type=='Credit – Balance Recoupment'){ ownerId = ca.Case__r.OwnerId; caseId.add(ca.Case__c); System.debug('Case ID | ' + caseId); } } Id receiveDocId = Schema.SObjectType.Case_Activity__c.getRecordTypeInfosByName().get('Receive Document').getRecordTypeId(); System.debug('receive doc Rec |' + receiveDocId ); Id ContProviderId = Schema.SObjectType.Case_Activity__c.getRecordTypeInfosByName().get('Contact Provider').getRecordTypeId(); System.debug('Contact Provider Rec |' + ContProviderId ); Id ConCredBalId = Schema.SObjectType.Case_Activity__c.getRecordTypeInfosByName().get('Confirm Credit Balance').getRecordTypeId(); System.debug('Credit Balance Rec |' + ConCredBalId ); Id BillIssueId = Schema.SObjectType.Case_Activity__c.getRecordTypeInfosByName().get('Verify Provider Billing Issues').getRecordTypeId(); System.debug('Billing Issue Rec |' + BillIssueId ); list<id> st_RecTyId = new list<id>(); st_RecTyId.add(creditbalreportId); st_RecTyId.add(receiveDocId); st_RecTyId.add(ContProviderId); st_RecTyId.add(ConCredBalId); st_RecTyId.add(BillIssueId); List<Case_Activity__c> caActList = [Select id,Name, Case__c,Activity_Business_Status__c,Status__c from Case_Activity__c Where Case__c =:CaseId AND RecordTypeId IN: st_RecTyId]; for(Case_Activity__c cAct : caActList){ If(cAct.Activity_Business_Status__c != 'Activity Not Applicable'){ cAct.Activity_Business_Status__c = 'Activity Not Applicable'; } if(cAct.Status__c != 'Completed'){ cAct.Status__c = 'Completed'; } Up_casActList.add(cAct); } System.debug('casActList Size | ' + casActList.size()); If(Up_casActList.size() > 0){ Update Up_casActList; Case cs = new Case(); cs.Case_Name__c= 'Provider Audit - Onsite'; cs.Type='Provider Audit - Onsite'; cs.OwnerId = ownerId; insert cs; } }
Thanks In Advance.
Soundar.
I corrected above code and make some changes.. Your Idea is little bit of usefull to myself (Thanks for your valuable Support Tej Pal).
Trigger:
Thnaks.
All Answers
Please change your query in line 42 'Where Case__c =:CaseId ' to 'Where Case__c IN : CaseId '.
If this answers your question mark Best Answer it as solution and then hit Like!
I corrected above code and make some changes.. Your Idea is little bit of usefull to myself (Thanks for your valuable Support Tej Pal).
Trigger:
Thnaks.