You need to sign in to do that
Don't have an account?
ApexDev
Apex class to fill the lookup field
Hi Everyone! :) On PricebookEntry object, I have a 2 lookup fields:
- Pricebook2Id (standard field filled by Integration)
- Price_Book_2__c (custom field needed for Related list)
I want to fill the Price_Book_2__c using the value in Pricebook2Id. I am trying to write the class, it will be my first apex class, I invoke it using Flow and later Process Builder, but the field is still empty
public class PriceBookField
{
@InvocableMethod
public static void PriceBookField(List<Id> PBIds){
List<PricebookEntry> XYZ = [Select Id, Pricebook2Id, Price_Book_2__c from PricebookEntry where ID in: PBIds];
for(PricebookEntry PB : XYZ){
PB.Price_Book_2__c = PB.Pricebook2Id;
}
update XYZ;
}
}
- Pricebook2Id (standard field filled by Integration)
- Price_Book_2__c (custom field needed for Related list)
I want to fill the Price_Book_2__c using the value in Pricebook2Id. I am trying to write the class, it will be my first apex class, I invoke it using Flow and later Process Builder, but the field is still empty
public class PriceBookField
{
@InvocableMethod
public static void PriceBookField(List<Id> PBIds){
List<PricebookEntry> XYZ = [Select Id, Pricebook2Id, Price_Book_2__c from PricebookEntry where ID in: PBIds];
for(PricebookEntry PB : XYZ){
PB.Price_Book_2__c = PB.Pricebook2Id;
}
update XYZ;
}
}