You need to sign in to do that
Don't have an account?
CBradley1985
Simple Update Trigger
Hello,
I am very very new to Apex...And need some help so any help would be greatly appreciated!
I am trying to figure out how to write a trigger to do the job of a WFR. I would use a WFR but it won't update a field on a different object.
What I'm trying to accomplish is when Inventory Reports__c on the Account record is equal to "None" it will update field Reports__c on my custom object "Inventory" to "Deactivate".
Also, a point in the direction to help me on my learning path would be a great help!
Thank you,
Chris
Please check this trigger code.
trigger Update_Inventory on Inventory (before insert) {
system.debug('**************Trigger Fired********************');
List<Inventory> invNew = Trigger.new;
List<Inventory> invUpdate = new List<Inventory>();
List<Account> accNew = Trigger.new;
for(Account a: accNew)
{
if(a.Reports__c == 'None')
{
for(Inventory inv : invNew)
{
inv.Reports__c = 'Deactivate';
}
invUpdate.add(inv);
}
}
}
It will help your need.
Thanks,
Bujji