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
Amit Jadhav 13Amit Jadhav 13 

FIELD_CUSTOM_VALIDATION_EXCEPTION, Please Enter GST Reg No. on corresponding Account: []

@isTest
public class OpportunityAmountInWordsTest
{
  
    Public static testmethod void OpportunityAmountInWordsTM()
    {
        RecordType rt = [select id,Name from RecordType where SobjectType='Account' and Name='Supplier' Limit 1];
        Account Acc =New Account();
            Acc.RecordTypeId=rt.id;
            Acc.Name='Test';
            Acc.GST_Reg_No__c='test1';
            Acc.TAX_IDENTIFICATION_NUMBER_VAT__c='Test11';
            Acc.IMPORT_EXPORT_CODE_IEC__c='test12';
            Insert Acc;
       
       Product2 Pro =New Product2 ();
            Pro.Name ='tEST';
            Pro.CurrencyIsoCode='USD';
            Insert Pro;
       Order odd =New Order();
            odd.AccountId=acc.id;
            odd.EffectiveDate=System.today();
            odd.Status__c='Draft';
            odd.Product_Name__c=pro.id;
            odd.Quantity__c=1234;
            odd.Quantity_per_Container__c=23;
            odd.Quantity_per_Packaging_Material__c =55;
            odd.Status='Draft';
            Insert odd;
            
        Opportunity opp =New Opportunity();
            opp.Name='Test';
            opp.accountId = Acc.id;
            opp.CloseDate=system.today();
            opp.CurrencyIsoCode ='USD';
            opp.Worked_by__c='Neha';
            opp.Product_Name__c=pro.id;
            opp.Description_of_Goods__c='test';
            opp.Origin__c='test';
            opp.Packaging_Details__c='trueuus';
            opp.Quantity__c=10000;
            opp.H_S_Code__c='amit';
            opp.Container_Size__c='20 FCL';
            // opp.Agent_Name__c=Customer.id;
            opp.StageName='Enquiry';
            // opp.Agent_Fee_IO__c=123;
            Insert opp;
            
            List<Cost_Price__c> lCostPr = new List<Cost_Price__c>();
            Cost_Price__c Cost1 =New Cost_Price__c();
            Cost1.Opportunity__c=opp.id;
            Cost1.Supplier_Name__c=Acc.id;
            //Cost1.Opportunity__c=opp.Accountid;
            Cost1.Country_of_Final_Destination_Picklist__c='India';
            Cost1.CurrencyIsoCode='USD';
            Cost1.UOM__c='Tonnes';
            cost1.Payment_Status__c = 'DUE';
            cost1.Payment_Receivable_Date__c = System.now().date().addDays(-40);
               
           lCostPr.add(cost1);
            Insert lCostPr;          
           
}
    
}
Umesh RathiUmesh Rathi
Hi Amit,

Please check Validation Rules on Account Object. There would be a Validation rule which is preventing you from inserting an Account.
The GST_Reg_No__c field is not satisfying the criteria mentioned in the Validation rule. Line :Acc.GST_Reg_No__c='test1';
Please assign a valid GST_Reg_No__c while inserting Account as per the conditions written in the Validation Rule.

Thanks,
Umesh
Amit Jadhav 13Amit Jadhav 13
hey Umesh 
Thanks For Reply i wrote validation rule for error if GST_Reg_No__c is null then show msg please fill that .


thanks
Amit