Skip to main content
added 271 characters in body
Source Link
techtrekker
  • 18.4k
  • 1
  • 45
  • 50

Pbook2Id is a collection, so it doesnt have a field called Id.

The dot notation to access a field can only be used on an sObject (you can access static / instance variables using Class / Object names too)

In summary,

AND
PriceBook2Id IN : Pbook2Id

This works in Apex for an ID Field, if it didn't you'd have to construct a List for comparison

List<Id> PriceBookIds = new List<Id>();
for(PriceBook2 pb : Pbook2Id) //iterate over the list and collect ids for comparison
PriceBookIds.add(pb.Id);

and then use

PriceBook2Id IN :PriceBookIds

You can also cast to a Map dynamically and use the keySet for comparison

eg

Map<Id, Pricebook2> Pbook2Id = new Map<Id, PriceBook2>([SELECT Id, Name
                                FROM Pricebook2 
                                    WHERE Name='Support Renewal' AND IsActive=true]);

And then Use

PriceBook2Id IN :Pbook2Id.keySet()

Pbook2Id is a collection, so it doesnt have a field called Id.

The dot notation to access a field can only be used on an sObject (you can access static / instance variables using Class / Object names too)

In summary,

AND
PriceBook2Id IN : Pbook2Id

This works in Apex for an ID Field, if it didn't you'd have to construct a List for comparison

List<Id> PriceBookIds = new List<Id>();
for(PriceBook2 pb : Pbook2Id) //iterate over the list and collect ids for comparison
PriceBookIds.add(pb.Id);

and then use

PriceBook2Id IN :PriceBookIds

You can also cast to a Map dynamically and use the keySet for comparison

eg

Map<Id, Pricebook2> Pbook2Id = new Map<Id, PriceBook2>([SELECT Id, Name
                                FROM Pricebook2 
                                    WHERE Name='Support Renewal' AND IsActive=true]);

And then Use

PriceBook2Id IN :Pbook2Id.keySet()

Pbook2Id is a collection, so it doesnt have a field called Id.

The dot notation to access a field can only be used on an sObject (you can access static / instance variables using Class / Object names too)

In summary,

AND
PriceBook2Id IN : Pbook2Id

This works in Apex for an ID Field, if it didn't you'd have to construct a List for comparison

List<Id> PriceBookIds = new List<Id>();
for(PriceBook2 pb : Pbook2Id) //iterate over the list and collect ids for comparison
PriceBookIds.add(pb.Id);

and then use

PriceBook2Id IN :PriceBookIds

You can also cast to a Map dynamically and use the keySet for comparison

Map<Id, Pricebook2> Pbook2Id = new Map<Id, PriceBook2>([SELECT Id, Name
                                FROM Pricebook2 
                                    WHERE Name='Support Renewal' AND IsActive=true]);

And then Use

PriceBook2Id IN :Pbook2Id.keySet()
added 271 characters in body
Source Link
techtrekker
  • 18.4k
  • 1
  • 45
  • 50

Pbook2Id is a collection, so it doesnt have a field called Id.

The dot notation to access a field can only be used on an sObject (you can access static / instance variables using Class / Object names too)

In summary,

AND
PriceBook2Id IN : Pbook2Id

This works in Apex for an ID Field, if it didn't you'd have to construct a List for comparison

List<Id> PriceBookIds = new List<Id>();
for(PriceBook2 pb : Pbook2Id) //iterate over the list and collect ids for comparison
PriceBookIds.add(pb.Id);

and then use

PriceBook2Id IN :PriceBookIds

You can also cast to a Map dynamically and use the keySet for comparison

eg

Map<Id, Pricebook2> Pbook2Id = new Map<Id, PriceBook2>([SELECT Id, Name
                                FROM Pricebook2 
                                    WHERE Name='Support Renewal' AND IsActive=true]);

And then Use

PriceBook2Id IN :Pbook2Id.keySet()

Pbook2Id is a collection, so it doesnt have a field called Id.

The dot notation to access a field can only be used on an sObject (you can access static / instance variables using Class / Object names too)

In summary,

AND
PriceBook2Id IN : Pbook2Id

Pbook2Id is a collection, so it doesnt have a field called Id.

The dot notation to access a field can only be used on an sObject (you can access static / instance variables using Class / Object names too)

In summary,

AND
PriceBook2Id IN : Pbook2Id

This works in Apex for an ID Field, if it didn't you'd have to construct a List for comparison

List<Id> PriceBookIds = new List<Id>();
for(PriceBook2 pb : Pbook2Id) //iterate over the list and collect ids for comparison
PriceBookIds.add(pb.Id);

and then use

PriceBook2Id IN :PriceBookIds

You can also cast to a Map dynamically and use the keySet for comparison

eg

Map<Id, Pricebook2> Pbook2Id = new Map<Id, PriceBook2>([SELECT Id, Name
                                FROM Pricebook2 
                                    WHERE Name='Support Renewal' AND IsActive=true]);

And then Use

PriceBook2Id IN :Pbook2Id.keySet()
Source Link
techtrekker
  • 18.4k
  • 1
  • 45
  • 50

Pbook2Id is a collection, so it doesnt have a field called Id.

The dot notation to access a field can only be used on an sObject (you can access static / instance variables using Class / Object names too)

In summary,

AND
PriceBook2Id IN : Pbook2Id