You need to sign in to do that
Don't have an account?
ApexDev
Simple 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 some class, it will be my first apex class, and still I get errors...
I want to run it from Flow.
Here is code:
public class PriceBookField{
@InvocableVariable(label='Get Price Book records')
public PriceBookEntry p;
@InvocableMethod
public static void populateField(List<PricebookEntry>records){
records[0].Price_Book_2__c = records[0].Pricebook2Id;
update records;
}
}
Can you help me?
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 some class, it will be my first apex class, and still I get errors...
I want to run it from Flow.
Here is code:
public class PriceBookField{
@InvocableVariable(label='Get Price Book records')
public PriceBookEntry p;
@InvocableMethod
public static void populateField(List<PricebookEntry>records){
records[0].Price_Book_2__c = records[0].Pricebook2Id;
update records;
}
}
Can you help me?
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;
}
}