+ Start a Discussion
Amol ChAmol Ch 

Field filter throwing error in test class

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

in my test class, i'm creating my test data like;
 
@Istest(SeeAllData=false)
public class test1{
  Static testmethod void test12()
    {
     job__c job= new Job__c();
     //job fields
      job.Service_Type__c='ABC';
insert job;

 Patient_Services__c ps = new Patient_Services__c();
     //ps fields
     ps.Service_Type__c='ABC';
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.
 
Amit Chaudhary 8Amit Chaudhary 8
Please try below code.
@IsTest
public class test1
{
	Static testmethod void test12()
    {
		job__c job= new Job__c();
			//job fields
			job.Service_Type__c='ABC';
		insert job;

		Patient_Services__c ps = new Patient_Services__c();
			ps.Job__c  = job.id;
			//ps fields
			ps.Service_Type__c='ABC';
		insert ps
	}
}
Let us know if this will help you
 
Amol ChAmol Ch
Hi Amit,

sorry that field i forgot to write here. no issue about field(ps.Job__c = job.id;) i have already in my code.
Amol ChAmol Ch
Please suggest why this is throwing error?