You need to sign in to do that
Don't have an account?
Dee Dee Aaron
Can you please help write a test class?
Hi. With the help of the community, I was able to setup a trigger.
Could you please help me write a test class for this? Thank you for your help!
trigger FeedCommentUpdatetoNetPlanning on FeedComment (after insert)
{
Id profileId = UserInfo.getProfileId();
String profileName =[Select Id, Name from Profile where Id=:profileId].Name;
Set<id> SalesEngineeringSet = new Set<Id>();
List<SALES_ENGINEERING_REQUEST__c> serList = new List<SALES_ENGINEERING_REQUEST__c>();
for(FeedComment f : Trigger.New)
{
if(profileName == 'GeoLinks Net Planning')
{
SalesEngineeringSet.add(f.ParentId);
}
}
if(!SalesEngineeringSet.IsEmpty()){
for(SALES_ENGINEERING_REQUEST__c ser : [SELECT ID,Status__c FROM SALES_ENGINEERING_REQUEST__c WHERE ID In: SalesEngineeringSet]){
if(ser.Status__c != 'Approved' && ser.Status__c != 'Unable to Meet Request'){
ser.Status__c = 'Awaiting Response from Net Planning';
serList.add(ser);
}
}
}
if(!serList.IsEmpty())
update serList;
}
Could you please help me write a test class for this? Thank you for your help!
trigger FeedCommentUpdatetoNetPlanning on FeedComment (after insert)
{
Id profileId = UserInfo.getProfileId();
String profileName =[Select Id, Name from Profile where Id=:profileId].Name;
Set<id> SalesEngineeringSet = new Set<Id>();
List<SALES_ENGINEERING_REQUEST__c> serList = new List<SALES_ENGINEERING_REQUEST__c>();
for(FeedComment f : Trigger.New)
{
if(profileName == 'GeoLinks Net Planning')
{
SalesEngineeringSet.add(f.ParentId);
}
}
if(!SalesEngineeringSet.IsEmpty()){
for(SALES_ENGINEERING_REQUEST__c ser : [SELECT ID,Status__c FROM SALES_ENGINEERING_REQUEST__c WHERE ID In: SalesEngineeringSet]){
if(ser.Status__c != 'Approved' && ser.Status__c != 'Unable to Meet Request'){
ser.Status__c = 'Awaiting Response from Net Planning';
serList.add(ser);
}
}
}
if(!serList.IsEmpty())
update serList;
}
I remember posting the following sample code in one of the previous posts