You need to sign in to do that
Don't have an account?
sam patil
help me to write test class on this trigger
#triggerHandler
public static void SetState(list <Child__c> childnewlst){
set<id> parentids= new set<id>();
for(Child__c child : childnewlst ){
parentids.add(child.parent__c);
}
list<parent__c> parentlist = new list <parent__c>();
if(!parentids.isEmpty()){
parentlist=[select id,state__c, (select id, state__c from child__r where state__c != null)
from parent__c where id in : parentids];
}
list<parent__c> parenttoupdate = new list <parent__c>();
for(parent__c parent : parentlist){
string state ='';
if(!parent.child__r.isEmpty()){
for(child__c child : parent.child__r){
if(!state.contains(child.state__c)){
state = state + child.state__c + ';';
}
}
parent.State__c = state;
parentToUpdate.add(parent);
}
if(!parentToUpdate.isEmpty()){
update parentToUpdate;
}
}
}
}
public static void SetState(list <Child__c> childnewlst){
set<id> parentids= new set<id>();
for(Child__c child : childnewlst ){
parentids.add(child.parent__c);
}
list<parent__c> parentlist = new list <parent__c>();
if(!parentids.isEmpty()){
parentlist=[select id,state__c, (select id, state__c from child__r where state__c != null)
from parent__c where id in : parentids];
}
list<parent__c> parenttoupdate = new list <parent__c>();
for(parent__c parent : parentlist){
string state ='';
if(!parent.child__r.isEmpty()){
for(child__c child : parent.child__r){
if(!state.contains(child.state__c)){
state = state + child.state__c + ';';
}
}
parent.State__c = state;
parentToUpdate.add(parent);
}
if(!parentToUpdate.isEmpty()){
update parentToUpdate;
}
}
}
}
Hey Sam,
Hope you are doing good.
Have you made any attempt for writing a test class for this ?
If Yes, kindly share here, we can help you anywhere needed.
Thanks & Regards,
Priya Ranjan
can you plese share code ,