You need to sign in to do that
Don't have an account?
Error: Compile Error: Invalid field
I am creating a test class for an Apex class. My code:
@isTest
public class LsUnitListTest
{
static testMethod void testLsUnitListPage()
{
Lease__c objLease = new Lease__c(Name = 'Test Lease');
insert objLease;
List<Lease_Unit_Association__c> lstUnit = new List<Lease_Unit_Association__c>{ new Unit__c( Unit__c = 'Test Unit1', Unit__c = objLease.ID, Property_Unit__r.Unit_Status_Code__c = 'N'),
I am encountering the following error:
Error: Compile Error: Invalid field Unit__c for SObject Unit__c at line 10 column 115
I am not quite sure what it is telling me. Do I have an invalid field type in the test? I get the feeling it is something obvious. Any help would be appreciated. Thanks.
@isTest
public class LsUnitListTest
{
static testMethod void testLsUnitListPage()
{
Lease__c objLease = new Lease__c(Name = 'Test Lease');
insert objLease;
List<Lease_Unit_Association__c> lstUnit = new List<Lease_Unit_Association__c>{ new Unit__c( Unit__c = 'Test Unit1', Unit__c = objLease.ID, Property_Unit__r.Unit_Status_Code__c = 'N'),
I am encountering the following error:
Error: Compile Error: Invalid field Unit__c for SObject Unit__c at line 10 column 115
I am not quite sure what it is telling me. Do I have an invalid field type in the test? I get the feeling it is something obvious. Any help would be appreciated. Thanks.
Also - yeah - you can't set a formula field. You still have something funky going on with this "Unit__c = 'Test Unit1', Unit__c = objLease.ID" piece.