+ Start a Discussion
Amol ChAmol Ch 

Field filter throws error in test class, even if criteria meet correct

I' ve one object Patient service and job is look up field on same object. field job has look up filter enable as below.
User-added image
@IsTest
public class test1
{
	Static testmethod void test12()
    {
		Job__c job= new Job__c();
            job.skdate__Finish__c = '20/08/2014 8:30 AM';
            job.skdate__Start__c = '18/08/2014 8:30 AM';
            job.Invoice_Start__c = DateTime.parse('18/08/2014 8:30 AM');
            job.Invoice_Finish__c = DateTime.parse('20/08/2014 8:30 AM');
            job.sked__Duration__c = 501;
            job.sked__Region__c = Reg.Id;
            job.sked__Type__c='Podiatry Clinic';
            job.Job_Billable__c =true;
            job.Service_Type__c='Podiatry';
            job.Resource_Name__c=Res.Name;
            insert job;
               
        Patient_Services__c ps = new Patient_Services__c();
            ps.Service_Type__c = 'Podiatry';
            ps.Job__c = job.id;
            ps.Who_to_Invoice__c='Medicare Account';
             ps.Patient_Service_Invoice_Start__c=DateTime.parse('18/08/2014 8:30 AM');
            ps.Patient_Service_Invoice_Finish__c=DateTime.parse('20/08/2014 8:30 AM');
            ps.Patient_Service_Lunch__c='10';
            insert ps;
	}
}
at the line insert ps  it throwing error as below

Value does not exist or does not match filter criteria.: [Job__c]

Please suggest what wrong here.
 
veda Hebbarveda Hebbar
Hi Amol,

I think the 'Jib.Id' your are referring in line 21 is not matching filter criteria. So it is giving exception. Please check the referred job is matching filter criteria of lookup field.

Thanks,
Veda