You need to sign in to do that
Don't have an account?
![Chuck Harvey Chuck Harvey](https://dfc-org-production.my.site.com/img/userprofile/default_profile_45_v2.png)
Problem creating a class when inserting a new record
I have a custom object I created called Customer Fact Sheet. When I save in the Customer Fact Sheet, I want a new record to create in the Status Report object with the Status_Unique_ID the same as what is in CUstomer Fact Sheet. I am trying to create a class that will create a new record and pass the Status Unique ID. The Error I am getting is Status Unique ID column is not in the Status Report object. I cannot figure out why because I am copying the API name from the Status Report object so it should be a match. After I get these solved, I would like to see there is no duplicate before I insert.
@isTest
public class StatusID {
static testmethod void insertID() {
List<Customer_Fact_Sheet__c> result = [SELECT Status_Unique_ID__c FROM Customer_Fact_Sheet__c
WHERE Status_Unique_ID__c = :ApexPages.currentPage().getParameters().get(' Status_Unique_ID__c')];
{ if (result.size() > 0)
Status_Report__c IStatus = new Status_Report__c();
IStatus.Status_Unique_ID__c = result[0].Status_Unique_ID__c;
insert IStatus;
}
}
}
Error: Compile Error: Variable does not exist:IStatus:Status_Unique_ID__c at line 8 column 9
@isTest
public class StatusID {
static testmethod void insertID() {
List<Customer_Fact_Sheet__c> result = [SELECT Status_Unique_ID__c FROM Customer_Fact_Sheet__c
WHERE Status_Unique_ID__c = :ApexPages.currentPage().getParameters().get(' Status_Unique_ID__c')];
{ if (result.size() > 0)
Status_Report__c IStatus = new Status_Report__c();
IStatus.Status_Unique_ID__c = result[0].Status_Unique_ID__c;
insert IStatus;
}
}
}
Error: Compile Error: Variable does not exist:IStatus:Status_Unique_ID__c at line 8 column 9
List<Customer_Fact_Sheet__c> result = [SELECT Status_Unique_ID__c FROM Customer_Fact_Sheet__c I understand that the field Status_Unique_ID__c is in Object : Customer_Fact_Sheet__c
Do you have the same field with the same name in Status_Report__c object? If not, please replace it with the correct name in line:
IStatus.Status_Unique_ID__c = result[0].Status_Unique_ID__c;
Thanks