As part of the first step of the Apex Specialist Superbadge project, I am trying to insert mock data like this:
//create test objects
Product2 testEquipment1 = new Product2(Name='Test Equipment 1',
Lifespan_Months__c=12);
Product2 testEquipment2 = new Product2(Name='Test Equipment 2',
Lifespan_Months__c=18);
insert testEquipment1;
insert testEquipment2;
Case testCase = new Case(Status='New',
Subject='Test Maintenance Request');
insert testCase;
Work_Part__c testWorkPart1 = new Work_Part__c(Equipment__c=testEquipment1.Id,
Maintenance_Request__c=testCase.Id);
Work_Part__c testWorkPart2 = new Work_Part__c(Equipment__c=testEquipment2.Id,
Maintenance_Request__c=testCase.Id);
insert testWorkPart1;
insert testWorkPart2;
As part of the setup for the project I installed this unmanaged package in my Trailhead Playground, which included the Work Part custom object. Here is what the Work Part objects and fields section looks like in my developer org:
I don't get any compiler errors, but I get the following error on insert testWorkPart1
when I try to run my test method:
System.DmlException: Insert failed. First exception on row 0; first error: FIELD_FILTER_VALIDATION_EXCEPTION, No spare parts meet this description or name.: [Equipment__c]
Is anyone familiar with what this error message means? I wasn't able to find any posts where others were getting a similar message. It's strange to me that the term "spare parts" is used, I'm not sure what that means in a Salesforce context. Does this mean that Equipment__c
isn't being recognized as a field on my Work Part object?