+ Start a Discussion

Trigger for getting auto number while using DATA Loader.


I have written one

 trigger {before insert, before update}


for(CustomObj__c t: Trigger.new)


system.debug('AutoID__c '+t.AutoID__c);



1. If I try to insert any record through UI , it will be possible to get the autonumber with the same trigger.

2.But if i try to run the data loader to insert any record ,its giving me 'Null' value.


So, i want the same trigger should work for Data loader as well.

Plz suggest some solution.






Willem Jan AllaartWillem Jan Allaart

I presume the AutoID__c field is an autonumber field.


As far as I know autonumbers are assigned during the actual insert and therefore are not available at the moment the before insert trigger is fired.

During before insert it will return a null value. It doesn't matter if the record is inserting through the UI or the data loader.