I have two fields.
Cost_price__c
& Previous_book_value__c
Currently, I use a Trigger on my Asset object to create a bunch of other objects and related records. However, I need to map the field of Previous_book_value__c
to the same as Cost_price__c
to work with them both.
I can't use the Previous_book_value__c
as a formula field, I need them both to remain as a Currency field.
My plan is to add a second Trigger Context variable to deal with the field before inserting as inserting afterwards won't work. I feel like it's simple and I'm over complicating the entire process.
Could I get some indication on where to get started please?
Many thanks
Code:
trigger CreateProjectfromAsset on Asset (before insert, after insert, after update) {
if(Trigger.isInsert){
if(Trigger.isAfter){
AssetCreationController.assetCreation(Trigger.new);
}
if(Trigger.isBefore){
System.debug('Need to set the field value of Previous_book_value__c to be the same as Cost_price__c');
}
}
}
if(Trigger.isUpdate ){
AssetCreationController.assetUpdate(Trigger.new);
}
}
Currency
. Looking at your requirements, it seems better to create the field as formula.Worfklow Rule Field Update
.