You need to sign in to do that
Don't have an account?

Trigger Help please
I have a field named Total Students... and trying to do a count() on the object but can not get it to work...
It keeps bringing up this error:
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger TTLs caused an unexpected exception, contact your administrator: TTLs: execution of AfterUpdate
caused by: System.Exception: Record is read-only: Trigger.TTLs: line 7, column 9
trigger TTLs on Account (after update) { List<Account> udte = new List<Account>(); Integer accs; accs=[Select count() from Account where RecordType.Name='Student']; for(Account hr: trigger.old) { hr.Total_Students__c=accs; htoUpdte.add(hr); } }
Yes I check the field level security, everything is editable about this field...
Where am I going wrong...
I am trying to add some data to a field.
But it gives me this error...
Apex trigger handleProjectManagerLookup caused an unexpected exception, contact your administrator: handleProjectManagerLookup: execution of AfterUpdate caused by: System.Exception: Record is read-only: Trigger.handleProjectManagerLookup: line 7, column 6
I think the below code will work.
trigger handleProjectManagerLookup1 on Timesheet__c (after insert) { for(Timesheet__c objTimesheet:Trigger.New) { List<TimeEntry__c> TE = [Select t.Time__c, t.Notes__c From TimeEntry__c t WHERE t.Time__c = 23.00]; for (TimeEntry__c temp : TE){ temp.Notes__c = 'Meenakshi'; } update TE; } }
When I try to create a new timesheet record it still gives errors:
Apex trigger handleProjectManagerLookup1 caused an unexpected exception, contact your administrator: handleProjectManagerLookup1: execution of AfterInsert caused by: System.DmlException: Update failed. First exception on row 0 with id a08A0000000r3A0IAI; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, handleProjectManagerLookup: execution of AfterUpdate caused by: System.Exception: Record is read-only Trigger.handleProjectManagerLookup: line 7, column 6: []: Trigger.handleProjectManagerLookup1: line 9, column 3
Whereas trying to create a new timeentry record gives the same old Record is readonly error
check the Timesheet list size
If the size() > 1 then update the object.