function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ashish P.Ashish P. 

my trigger is not working. please help

I have to write a trigger that updates the filed when the record type field is filled. Following is the trigger I wrote but dont know why it is not working. can any one help:

 

trigger name on Object__c (after insert, after update, before insert, before update) {
// for food test date = abc last test date

// query for all record type = food test

}

 

Laxman RaoLaxman Rao

If the field is on the same object you can do this using before trigger.

 

Can you be specific which and what field you want to update and which object???

Ashish P.Ashish P.

Thankx laxman for your help. Here is the details for that: 

 

I have a object name ER has two fields FE last date and GE last date. and there a object NBA which has a record type name FD. Now I have to write a trigger that auto poppulate the FE last date field with the Inspection date in record type FD. Also it should pick up the last date. 

 

I hope this makes it clear

Laxman RaoLaxman Rao

Do you mean to say when ever the ER instance is created, you should populate the FE last date using the record type FD created date or last modified date???

Ashish P.Ashish P.

No there is already ER it is not cretaed but when ever there is FD created it had mutilple dates in it . The trigger should pick the latest date and populate the FE field.

Laxman RaoLaxman Rao

Select the latest date using this :

SELECT Max(DateField) FROM TableName