I am trying to create a test data for coverage. The field is a formula field and it has a master-detail relationship with another object, then I create a recode in the object. but how can I reference the field in the detail object? I am getting an error:
Field is not writeable
How Can I do that?
The PLS_Code__c
is a formula field and formulae are: Positioner_Limit_Switch__r.Code__c
VWC_Positioner_LimitSwitch__c PLSObj = new VWC_Positioner_LimitSwitch__c();
PLSObj.Code__c = '2HPB';
PLSObj.Description__c = 'This is test data.';
insert PLSObj;
VWC_PLS_Combination__c pls_Combination = new VWC_PLS_Combination__c();
pls_Combination.Price__c = 123;
pls_Combination.Positioner_Limit_Switch__r.Code__c = PLSObj.id;
insert pls_Combination;
instance.selectedPositioner = '2HPB';`