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
Huy NguyenHuy Nguyen 

field_custom_validation_exception

Hi all,

I have 2 code test class below :
Date d = date.today();
        Disclosure_Claim_for_Payment__c dcp = new Disclosure_Claim_for_Payment__c(
            Disclosure_Obligation__c = doc.Id,
            Stakeholder__c = accountPerson.Id,
            Eligible_Claim_for_Payment__c = ecp.Id,
            RecordTypeId = listRecordType.get('Claim for Payment (Administration Fund)'),
            Payment_Term__c = '2nd Quarterly Payment',
            status__c = 'Closed',
            Date_Checked__c=d,
            Cumulative_Maximum_Claimable_Amount__c = 100,
            Total_Claim_Amount__c = 100);

and

        Disclosure_Claim_for_Payment__c dcp = new Disclosure_Claim_for_Payment__c(
            Disclosure_Obligation__c = doc.Id,
            Stakeholder__c = accountPerson.Id,
            Eligible_Claim_for_Payment__c = ecp.Id,
            RecordTypeId = listRecordType.get('Claim for Payment (Administration Fund)'),
            Payment_Term__c = '2nd Quarterly Payment',
            status__c = 'Closed',
            Date_Checked__c=date.today(),
            Cumulative_Maximum_Claimable_Amount__c = 100,
            Total_Claim_Amount__c = 100);

The first code when I run test it is ok. But the second code it thrown exception field_custom_validation_exception. I see the code it is the same. Please help me why the second code thown exception although it is passed in sandbox but failed in production
Jagan ReddyJagan Reddy
Hi,

give another record type id in second code and try it.
Huy NguyenHuy Nguyen
Hi Jagan,

No it mean when i use the first code it is passed in sandbox and production but the second code it is failed in production but pass in sandbox. It is different only 1 line but i think they are same meaning.I have validation rule checked date_check__c is not blank . 2 code are created the value for that field. I do not know why the second code is failed

Date d = date.today();
        Disclosure_Claim_for_Payment__c dcp = new Disclosure_Claim_for_Payment__c(
            Disclosure_Obligation__c = doc.Id,
            Stakeholder__c = accountPerson.Id,
            Eligible_Claim_for_Payment__c = ecp.Id,
            RecordTypeId = listRecordType.get('Claim for Payment (Administration Fund)'),
            Payment_Term__c = '2nd Quarterly Payment',
            status__c = 'Closed',
            Date_Checked__c=d,
            Cumulative_Maximum_Claimable_Amount__c = 100,
            Total_Claim_Amount__c = 100);

  Disclosure_Claim_for_Payment__c dcp = new Disclosure_Claim_for_Payment__c(
            Disclosure_Obligation__c = doc.Id,
            Stakeholder__c = accountPerson.Id,
            Eligible_Claim_for_Payment__c = ecp.Id,
            RecordTypeId = listRecordType.get('Claim for Payment (Administration Fund)'),
            Payment_Term__c = '2nd Quarterly Payment',
            status__c = 'Closed',
            Date_Checked__c=date.today(),
            Cumulative_Maximum_Claimable_Amount__c = 100,
            Total_Claim_Amount__c = 100);
 
Jagan ReddyJagan Reddy
Sorry Huy,

still i didn't get you.
Huy NguyenHuy Nguyen
Hi,


This one is run passed in sandbox but failed in production. Take a look the bold line

Date d = date.today();
        Disclosure_Claim_for_Payment__c dcp = new Disclosure_Claim_for_Payment__c(
            Disclosure_Obligation__c = doc.Id,
            Stakeholder__c = accountPerson.Id,
            Eligible_Claim_for_Payment__c = ecp.Id,
            RecordTypeId = listRecordType.get('Claim for Payment (Administration Fund)'),
            Payment_Term__c = '2nd Quarterly Payment',
            status__c = 'Closed',
            Date_Checked__c=d,
            Cumulative_Maximum_Claimable_Amount__c = 100,
            Total_Claim_Amount__c = 100);

This one is passed in production and sandbox.Please look the bold line

Disclosure_Claim_for_Payment__c dcp = new Disclosure_Claim_for_Payment__c(
            Disclosure_Obligation__c = doc.Id,
            Stakeholder__c = accountPerson.Id,
            Eligible_Claim_for_Payment__c = ecp.Id,
            RecordTypeId = listRecordType.get('Claim for Payment (Administration Fund)'),
            Payment_Term__c = '2nd Quarterly Payment',
            status__c = 'Closed',
            Date_Checked__c=date.today(),
            Cumulative_Maximum_Claimable_Amount__c = 100,
            Total_Claim_Amount__c = 100);

My questions is the code are the same meaning but one failed in production . The exception for the first code is :Insert failed field_custom_validation_exception . I have a validation rule the date_check__c is not blank