Who knows how best to approach this task. I was asked to add a TIN field to Account. This is the Polish taxpayer number for the firm. This field should be checked to be sure that the user entered it correctly. At the bottom under the text I leave a screenshot according to which rule this number is checked.
Is it possible to do something like this using Validation rule and the formulas it contains?
I've achieved something. I wrote a formula that would check the TIN. In my opinion, it should look like below in the insert with the code.
MOD(
(VALUE((MID( NIP__c , 0, 1)) * 6) +
(VALUE((MID( NIP__c , 1, 1)) * 5) +
(VALUE((MID( NIP__c , 2, 1)) * 7) +
(VALUE((MID( NIP__c , 3, 1)) * 2) +
(VALUE((MID( NIP__c , 4, 1)) * 3) +
(VALUE((MID( NIP__c , 5, 1)) * 4) +
(VALUE((MID( NIP__c , 6, 1)) * 5) +
(VALUE((MID( NIP__c , 7, 1)) * 6) +
(VALUE((MID( NIP__c , 8, 1)) * 7),
11) > 10
But for some reason a record returns to me with an error of the following content: Error: Syntax error. Missing ')'
I would be very grateful if someone would rate my formula and tell me if it is well written in general and where I need to put the parentheses. Because I have already run out of all possible options for how to put them.
Thank you for checking the original formula and for the explanations related to the placement of brackets. I've moved on. But my ValidationRule does not work as it should. This is what my formula looks like now.
MOD(
VALUE((MID( NIP__c , 0, 1))) * 6 +
VALUE((MID( NIP__c , 1, 1))) * 5 +
VALUE((MID( NIP__c , 2, 1))) * 7 +
VALUE((MID( NIP__c , 3, 1))) * 2 +
VALUE((MID( NIP__c , 4, 1))) * 3 +
VALUE((MID( NIP__c , 5, 1))) * 4 +
VALUE((MID( NIP__c , 6, 1))) * 5 +
VALUE((MID( NIP__c , 7, 1))) * 6 +
VALUE((MID( NIP__c , 8, 1))) * 7,
11) = 10
&&
MOD(
VALUE((MID( NIP__c , 0, 1))) * 6 +
VALUE((MID( NIP__c , 1, 1))) * 5 +
VALUE((MID( NIP__c , 2, 1))) * 7 +
VALUE((MID( NIP__c , 3, 1))) * 2 +
VALUE((MID( NIP__c , 4, 1))) * 3 +
VALUE((MID( NIP__c , 5, 1))) * 4 +
VALUE((MID( NIP__c , 6, 1))) * 5 +
VALUE((MID( NIP__c , 7, 1))) * 6 +
VALUE((MID( NIP__c , 8, 1))) * 7,
11) <> VALUE(MID( NIP__c , 9, 1))
It should check whether the entered TIN is correct. The first task
The next task. This is so that the second part of the formula checks that the last digit with TIN is equal to MOD 11. As in the screenshot below.
But in my case it looks like I can enter all the numbers and ValidationRule will accept everything. Unless it's just 9999999999
Who could help me at this stage of the Validation Rule build? Because at this stage everything has somehow changed places. ValidationRule accepts everything, there are no syntactic or any other errors, but I'm still not happy with the result. I've reached a dead end and now I don't know what to do with it all.
VALUE()
,MID()
,MOD()
from Formula Operators and Functions). This would be easier in Apex though. Beyond that, what have you tried? where are you stuck?