My company is using custom objects for Pricelist, Pricelist Items, and Products.
I'm having this error trying to test my method to get a return of the Pricelist object as a List of Id.
Line: 11, Column: 5 - "Static method cannot be referenced from a non static context: List IPriceDecorator.getPriceList(Id, Set)"
global class IPriceDecorator {
global static List<Pricelist__c> getPriceList(Id priceListId, Set<Id> setProdId) {
System.debug(LoggingLevel.ERROR, '__ [cls IPriceDecorator - getPriceList] - Start...');
//System.debug(LoggingLevel.ERROR, '__ [cls IPriceDecorator - getPriceList] - priceListId: ' + priceListId);
//System.debug(LoggingLevel.ERROR, '__ [cls IPriceDecorator - getPriceList] - setProdId: ' + setProdId);
List<Pricelist__c> priceList = [ SELECT Id
, Name
, IsActive__c
FROM Pricelist__c
WHERE Id =: setProdId ];
System.debug(LoggingLevel.ERROR, '__ [cls IPriceDecorator - getPriceList] - priceList: ' + priceList);
return priceList.isEmpty() ? null : priceList;
}
}
I'm running this snippet in Execute Anonymous.
String Id_Field = 'Id'; Id priceListId = 'a1t0O000005OsARQA0';
List<Product__c> prodList = [SELECT Id FROM Product__c];
System.debug('prodList: ' + prodList);
Set<Id> setProdId = new Set<Id>(); setProdId =
CollectionUtils.createSet(prodList, Id_Field);
System.debug('setProdId: ' + setProdId); IPriceDecorator obj = new
IPriceDecorator(); obj.getPriceList(priceListId, setProdId);
I really don't understand why this error occurs.