You need to sign in to do that
Don't have an account?
Test User 15
Task should be closed whenever Account close task updated
I created one Close Task checkbox in Account. Whenever I checked on Close Task in Account, all task should be closed.
I'm learning how to write triggers. I wrote a trigger but it's not working. Please look at it and help.
I'm learning how to write triggers. I wrote a trigger but it's not working. Please look at it and help.
trigger CloseTaskInAccount on Account (before update) { List<Account> acc = [Select Id From Account]; for(Account acc : Trigger.new) { Task t = new Task(); if(acc.Close_Task__c == True) { t.Status = 'Completed'; t.WhatId = acc.Id; update t; } } }
All Answers
Please use this code
It's working fine. Can you please explain it to me?
Thanks
Hello there,
I believe DML operation did not work with the before trigger event.
Could you please try this at a different trigger event.
Thanks sir, nicely explained and updated version is working fine.