function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Trigger problem on custom object

I need to Use TRigger for above Question also need Test Class for it. I have created custom object mentioned above. Can anyone help me in Trigger ANd Test Class ? Its urgent. 

Thanks in advance.User-added image
Best Answer chosen by sgss
trigger EFTTransactionStatusTrgger on EFT_Transaction_Status__c( before insert) {

    for(EFT_Transaction_Status__c eft : Trigger.New) {
       if(eft.Method_Name__c == 'Credit Card address Verify' && eft.Transaction_Status__c == 'Declined' && eft.SalesHeader__r.Status == 'Open') {
           Case case = new case();
           case.Account = eft.SalesHeader__r.Bill_To_Customer__c;
           case.Contact = eft.SalesHeader__r.Bill_To_Customer__c;
           case.recordType.Name = 'Assignment';
           case.origin = "Internal";
//in this ways you can set value of every field
            insert case;

test Class

private class testEFTTransactionStatus {

    @istest static void testInsertEFT() {

            EFT_Transaction_Status__c eft = new EFT_Transaction_Status__c (name='testEFT');
           eft.Method_Name__c = 'Credit Card address Verify' ;
           eft.Transaction_Status__c = 'Declined';
           eft.SalesHeader__c. = new Case(Status='Open');
            insert eft;

        List<Case> case =[SELECT Id FROM Case];

      System.assertEquals(true, Case.size()>0, 'should insert case');