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
sriram anilsriram anil 

how to write trigger bellow requirements

id(autogenerated)            name
---------------------------------------------
a-001                          aaa
a-002                          bbb
a-003                          ccc
-------------------------------------------
the above table i am delete  a002 and a003 records, again insert another record ,this time automatically start with  a002

how to write trigger  any one explain
Best Answer chosen by sriram anil
Keyur  ModiKeyur Modi
Hi,
you can query on the same object ..

let see in the detail,
suppose there is object like project__c where you want to implement this .

so in trigger what you can do is query on the object like this

project__c prj=new project__c();

prj=[SELECT id,Name FROM project__c ORDER BY createdDate DESC LIMIT1];

with this query you will get latest created records ID suppose that id is a-005

then after getting thoes value (a-005) you can increase(a-006) and assign to new created value.

Thanks,
Keyur Modi