Validate ABNs in Salesforce

In Configuration by WebmasterLeave a Comment

ABN

Share this Post

Data validation is an important and simple operation within Salesforce.

Well implemented data validation protects the integrity of your lifeblood, your data.

Australian Business Numbers identify a registered Australian business. They comprise of a 9 digit identifier with two check digits.

The check digits mean that we can do some simple arithmetic using the numbers to check that the ABN entered is valid.

Step 1

Goto the setupĀ menu and click on Customize for standard objects or create for custom objects.

Step 2

Locate validation rules and create a new rule. You will need to give the rule a name such as ABN_Check.

Step 3

When you create a validation rule the result needs to be true or false. If the formula equates to true, the rule will fire and prevent the record being saved. An error message will appear on the screen requiring the user to correct the data before saving.

Step 4

Enter the following formula (Assumes that your ABN field name is ABN__c):-

IF(ISBLANK(TRIM(SUBSTITUTE( ABN__c , ” “, “”))),false,
IF(ISNUMBER(TRIM(SUBSTITUTE( ABN__c , ” “, “”))),
IF(LEN(TRIM(SUBSTITUTE( ABN__c , ” “, “”)))<>11,true,
Mod((Value(Left(TRIM(SUBSTITUTE( ABN__c , ” “, “”)),1)) – 1) * 10 +
Value(Mid(TRIM(SUBSTITUTE( ABN__c , ” “, “”)),2,1)) * 1 +
Value(Mid(TRIM(SUBSTITUTE( ABN__c , ” “, “”)),3,1)) * 3 +
Value(Mid(TRIM(SUBSTITUTE( ABN__c , ” “, “”)),4,1)) * 5 +
Value(Mid(TRIM(SUBSTITUTE( ABN__c , ” “, “”)),5,1)) * 7 +
Value(Mid(TRIM(SUBSTITUTE( ABN__c , ” “, “”)),6,1)) * 9 +
Value(Mid(TRIM(SUBSTITUTE( ABN__c , ” “, “”)),7,1)) * 11 +
Value(Mid(TRIM(SUBSTITUTE( ABN__c , ” “, “”)),8,1)) * 13 +
Value(Mid(TRIM(SUBSTITUTE( ABN__c , ” “, “”)),9,1)) * 15 +
Value(Mid(TRIM(SUBSTITUTE( ABN__c , ” “, “”)),10,1)) * 17 +
Value(Mid(TRIM(SUBSTITUTE( ABN__c , ” “, “”)),11,1)) * 19, 89) <> 0),true))

Step 5

Make sure that you enter a meaningful error message and select it to appear either at the top of the page or next to a field.

Check that the rule is active and saveĀ it.

This configuration setting will make sure that the ABN entered is a valid number. What it doesn’t do is check that it is the correct number for the particular business. It will guard against typos, not stupidity.

Leave a Comment