You need to sign in to do that
Don't have an account?
Admin User 3354
Error in Accessing Standard & custom fields of Opportunity
I am not able to access standard & custom fields of Opportunity Object in my apex classes. It gives me error "Variable does not exist" even for standard fields of Opportunity.
Please copy your code here for better understanding
public class TestAttendanceUpdateTaxi
{
private static testMethod void TestinsertAttendance()
{
//Fetching Record Type for Taxi Obj
RecordType rt = [SELECT id, Name FROM RecordType WHERE SobjectType='Taxi__c' AND Name='Sherbet'];
Account account = new Account();
account.Name= 'Test Account';
insert account;
/*
//Insering into Opportunity
Opportunity opp = new Opportunity();
opp.Name = 'hello';
*/
//Inserting Record for Taxi Obj
Taxi__c OTaxi = new Taxi__c();
OTaxi.recordTypeId=rt.id;
OTaxi.Name = 'Tx912';
OTaxi.Company__c = '001q000000JwBJT';
OTaxi.Last_Attended_Date__c = System.today();
insert OTaxi;
//Retrive inserted Taxi
OTaxi = [select Name from Taxi__c where Id =: OTaxi.Id];
System.debug('Taxi Registration No :'+ OTaxi.Name);
//Inserting record for Attendance Object
Driver_Payment__c OAttendance = new Driver_Payment__c();
OAttendance.Campaign__c = '006q0000005VjjN'; //[SELECT Id FROM Opportunity WHERE Name = 'testbrand' LIMIT 1].Id;
OAttendance.Company_Name__c = account.Id; //'001q000000JwBJT';
OAttendance.Taxi_ID__c = OTaxi.Id;
OAttendance.Attended_Date__c = System.today();
OAttendance.Update_current_receipt_campaign__c = True;
OAttendance.Update_current_Superside_Livery_Campaign__c = True;
// OAttendance.Update_current_Tip_seat_campaign__c = True;
insert OAttendance;
System.debug('Inserted values in Attendance obj');
//updating attendance
OAttendance.Update_current_Tip_seat_campaign__c = True;
update OAttendance;
//Assert
Taxi__c ObjTaxi = [select Last_Attended_Date__c from Taxi__c where Name = 'Tx912' and Taxi__c.Company__c =: account.Id /*'001q000000JwBJT'*/ limit 1];
System.assertEquals(OAttendance.Attended_Date__c , ObjTaxi.Last_Attended_Date__c);
}
}
Please check field level security and Permission for Opportunity object for current profile.