You need to sign in to do that
Don't have an account?
farah sherif
guys im getting an error on the below test class can anyone help please
@isTest
public class AssetTriggerTest2 {
@isTest static void test(){
Account acc = new Account();
acc.Name = 'farah test';
insert acc;
Opportunity opp = new Opportunity();
opp.Name = 'tests';
opp.CloseDate = Date.today();
opp.StageName ='Demo';
opp.AccountId = acc.Id;
opp.Type='New';
opp.Demo_Date__c = Date.today();
opp.New_Vehicle_Feed_Provider__c ='AutoFunds';
insert opp;
Product2 p1 = new Product2();
p1.Family = '360 Suite';
p1.IsActive = true;
p1.Name ='360 Suite';
insert p1;
Id pricebookId = Test.getStandardPricebookId();
PricebookEntry pb1 = new PricebookEntry();
pb1.Product2Id =p1.Id;
pb1.Pricebook2Id = pricebookId;
pb1.UnitPrice = 100.00;
pb1.IsActive = true;
insert pb1;
OpportunityLineItem oli = new OpportunityLineItem(
OpportunityId = opp.Id,
Quantity = 5,
PricebookEntryId = pb1.Id,
TotalPrice = Quantity * pb1.UnitPrice
);
insert oli;
opp.StageName = 'Closed Won';
update opp;
}
}
error
Variable does not exist: Quantity
although it does exist and when i added a value to it it worked fine
public class AssetTriggerTest2 {
@isTest static void test(){
Account acc = new Account();
acc.Name = 'farah test';
insert acc;
Opportunity opp = new Opportunity();
opp.Name = 'tests';
opp.CloseDate = Date.today();
opp.StageName ='Demo';
opp.AccountId = acc.Id;
opp.Type='New';
opp.Demo_Date__c = Date.today();
opp.New_Vehicle_Feed_Provider__c ='AutoFunds';
insert opp;
Product2 p1 = new Product2();
p1.Family = '360 Suite';
p1.IsActive = true;
p1.Name ='360 Suite';
insert p1;
Id pricebookId = Test.getStandardPricebookId();
PricebookEntry pb1 = new PricebookEntry();
pb1.Product2Id =p1.Id;
pb1.Pricebook2Id = pricebookId;
pb1.UnitPrice = 100.00;
pb1.IsActive = true;
insert pb1;
OpportunityLineItem oli = new OpportunityLineItem(
OpportunityId = opp.Id,
Quantity = 5,
PricebookEntryId = pb1.Id,
TotalPrice = Quantity * pb1.UnitPrice
);
insert oli;
opp.StageName = 'Closed Won';
update opp;
}
}
error
Variable does not exist: Quantity
although it does exist and when i added a value to it it worked fine
Also, TotalPrice of OpportunityLineItem will be calculated automatically based on unitPrice and Quantity. I think you just delete TotalPrice=Quantity*pb1.UnitPrice.
All Answers
Also, TotalPrice of OpportunityLineItem will be calculated automatically based on unitPrice and Quantity. I think you just delete TotalPrice=Quantity*pb1.UnitPrice.