You need to sign in to do that
Don't have an account?
Alex Waddell 12
Update Account from Custom Object creation - Apex help
Hello everyone,
I am creating a trigger that should update a field on the account page called Fuzion_Billing_Date__c when there are 3 Communication_Note__c records created with the outcome of 'No Answer'
As of right now the code saves but the Fuzion_Billing_Date__c field is not updating when i test. I haven't written a test class yet, I just created three records on a test account to see if it would populate.
Below is my code, I have a feeling the problem lies between lines 10-15, i do not think i am calling for the update properly. Can anyone help me out?
I am creating a trigger that should update a field on the account page called Fuzion_Billing_Date__c when there are 3 Communication_Note__c records created with the outcome of 'No Answer'
As of right now the code saves but the Fuzion_Billing_Date__c field is not updating when i test. I haven't written a test class yet, I just created three records on a test account to see if it would populate.
Below is my code, I have a feeling the problem lies between lines 10-15, i do not think i am calling for the update properly. Can anyone help me out?
trigger billingDate on Account (After insert) { For(Account myAcc : Trigger.New){ List<Account> allAccounts = new List<Account>([Select id,Fuzion_Billing_Date__c from account where id in :Trigger.new]); List<Communication_Note__c> ThreeUnsuccessful = [Select Id From Communication_note__c Where Fuzion_Type__c = 'Initial Phone Call' AND Outcome__c = 'No Answer' And Id = : myAcc.Id]; If(ThreeUnsuccessful.size() == 3){ myAcc.Fuzion_Billing_Date__c = Date.today(); } Update myAcc; } }
Shouldn't i be doing "trigger billingDate on Communication_Note__c (After insert) {" rather than on the Account? since i want it to trigger on the third and final Comm note Creation?