WeDid: TAX FILE NUMBER CHECK AGAINST PRESET ALGORITHM

Challenges

The customer RTO business involves collection of student’s Tax File Number (TFN) for HEIMS reporting. We need to provide customer a method to validate the TFN number provided by students:

  • The TFN given must be in 8 or 9 digits format
  •  The TFN must fulfill algorithm checks based on a document given by customer

 

Solution

A trigger to check the TFN provided before the record is saved:

  • Use text instead of number so that ‘0’ is not omitted when it is a leading digit.
  • Length check to ensure TFN provided is either 8 or 9 characters. Throw error when it is not.
  • Two version of checking against algorithm, one for 8 characters, one for 9 characters. Throw error if it doesn’t pass the checking.

 

Related Objects Contact
Components Apex Class, Apex Trigger
Complexity Easy