You need to sign in to do that
Don't have an account?
SFAdmin5
need test class
Anyone have a test class for this trigger:
trigger ownerCopy on Lead (before Insert, before Update) { for(Lead x : Trigger.New){ if( ((String)x.OwnerId).substring(0,3) == '005' ){ x.Owner_Copy__c = x.OwnerId; } else{ x.Owner_Copy__c = null; } } }
Thanks!
try this
Will cover 100% code
Thanks! That works. I need a test class for almost the exact same trigger, but instead of the Lead object, the trigger's on the account object. Any idea what a test class would be for this trigger:
You can try this
let me know if any issues in it.
Thanks. TYour test class gets me 75% which is sufficient, but I'd really like to see if it's possible to get this to 100%. There's just one line that is not passing yout test class in the trigger (line 8):
Any idea how to get this trigger to pass 100% coverage?
Thanks I really appreciate it
Change your trigger to , I have not changed any logic of this just changed the represntation so that one less script statement and full code coverage.
And Test class to
It should give you 100% code coverage.
Let me know if any issues in it.
public class ART_CheckAvailableUsers
{
public static Set<string> getAvailableUsers(Set<string> userIdSet)
{
List<Event> userEventList = new List<Event>();
//Check if the user has an Out of Office status
userEventList = [SELECT Id, OwnerId FROM Event WHERE EndDateTime >= :System.Now() AND StartDateTime <= :System.Now() AND ShowAs Like 'Out of Office' AND OwnerId in :userIdSet];
//If s/he has OOO, then remove that user from the result set.
for(Event e : userEventList)
{
userIdSet.remove(e.OwnerId);
}
return userIdSet;
}
}