[SalesForce] regarding External entry point

i have one custom field called Unique_Vendor_Id__c on account object (external id checkbox checked) and its auto-number.

now in test class when i create account for test data Unique_Vendor_Id__c should be automatically created as soon as account created, and in controller i am fetching data from that Unique_Vendor_Id__c if available.

now when i run test class it gives me following error :

System.StringException: Invalid id: null

and in stack trace :

External entry point Class.VendorAndChargeCreationControllerTest.VendorAndChargeCreationControllerTestMethod1: line 45, column 1

so from this error i think autonumber field is not generating id at a time of account creation am i right?

please let me know do i have to change any thing in field for generating that autonumber field in test data?

thank you in advance.

Best Answer

As you haven't supplied any code this is only a guess based on a typical problem...

When something happens in the database changed field values (with the exception of object Id fields when records are created) are not automatically brought back into the Apex code. So you have to requery the data to see the new values.

Related Topic