You need to sign in to do that
Don't have an account?
Rudu
Pls Help Me How to write test class on my trigger its very urgent......
Hi Team,
I want To write This Trigger test class any one help me to how to write....
Approach:Write Custom Code in salesforce to stop deleting any event forcefully Through this event will not get deleted in salesforce even in outlook
- If someone need to really delete the event they need to click on extra checkbox and save then delete in salesforce
pls tell me is it correct trigger to this Apporch
Note: Pls Test Class Should Be Bulkify........
I want To write This Trigger test class any one help me to how to write....
Approach:Write Custom Code in salesforce to stop deleting any event forcefully Through this event will not get deleted in salesforce even in outlook
- If someone need to really delete the event they need to click on extra checkbox and save then delete in salesforce
pls tell me is it correct trigger to this Apporch
Note: Pls Test Class Should Be Bulkify........
trigger avoidDeletionEvent on Event (before delete) { for(event e:trigger.old) { if(e.Override_Deletion__c==false) e.addError('You do not have permission to delete this event'); } }
public class avoidDeletionEventTest
{
public static void avoidDeletionEventTestMethod()
{
Test.startTest();
Event vEvent = new Event();
vEvent.Subject = 'Test1';
vEvent.Override_Deletion__c = false;
// Populate other fields which are required on Event
insert vEvent;
Try{Delete vEvent; }Catch(Exception Ex){}
Test.stopTest();
}
}
Try this.
@isTest
public class SampleTest
{
static testMethod void testMethod()
{
Event evnt = new Event(Subject = 'Test Subject',ActivityDate=System.today(),Override_Deletion__c = false);
insert evnt;
Test.startTest();
delete evnt;
Test.stopTest();
}
}
Thanks,
Let me know, if you need any other information!
shiva.sfdc.backup@gmail.com
I will recommend you to start using trailhead to learn about test classes
1) https://trailhead.salesforce.com/modules/apex_testing
Please try below test class
Let us know if this will help you