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
rajesh kumar 10rajesh kumar 10 

Can any one help writing Test class for the below trigger?

trigger NCAccountApprovalSubmit on Account (after insert) {
   
   
     for (Account a : trigger.new) {
        if (a.RecordType_Name__c == 'Plant' && (a.Plant_Business_Type__c == 'New construction')
            && (a.plant_Type__c == 'potential plant')
            && (a.status__c!='active') && (a.super_region__c=='EAME')
            && (a.account_industry_type__c =='Power - Fossil'||a.account_industry_type__c =='O & G'))
        {
            Approval.ProcessSubmitRequest app = new Approval.ProcessSubmitRequest();
            app.setObjectId(a.id);
            Approval.ProcessResult result = Approval.process(app);
        }
       

    }
   
}
James LoghryJames Loghry
Have you even attempted to write your own Apex Test Class yet?  Seems like that is something you should look into before posting your "Do my work for me for free" post here.  See the following link for an intro to test code: https://developer.salesforce.com/page/An_Introduction_to_Apex_Code_Test_Methods
nitesh gadkarinitesh gadkari
@isTest

public class NCAccountApprovalSubmitTest {
         public static testmethod void methd1(){
                account a1=new account();
                a1.Name='WorldOne';
                a1.RecordType_Name__c='plant';
                a1.Plant_Business_Type__c='New construction';
                a1.plant_Type__c='potential plant';
                a1.status__c='inactive';
                a1.super_region__c='EAME';
                a1.account_industry_type__c='Power - Fossil';
                insert a1;
// Create an approval request for the account
        Approval.ProcessSubmitRequest req1 = 
            new Approval.ProcessSubmitRequest();
        req1.setComments('Submitting request for approval.');
        req1.setObjectId(a1.id);
        
        // Submit the approval request for the account
        Approval.ProcessResult result = Approval.process(req1);
        
        // Verify the result
        System.assert(result.isSuccess());      
     }       
}
// I Truely Support James but try this working code

Regards Nitesh