You need to sign in to do that
Don't have an account?
brunol11
CNPJ Validation Rules - Regras de Validação de CNPJ
Parte 1 - Digito Verificador 1 ( aos brasileiros: dá jóinha, please!)
IF( LEN(CPF_ou_CNPJ__c)= 14 , OR(AND(MOD((
( VALUE( MID( CPF_ou_CNPJ__c , 1, 1 ) ) * 6 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 2, 1 ) ) * 5 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 3, 1 ) ) * 4 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 4, 1 ) ) * 3 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 5, 1 ) ) * 2 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 6, 1 ) ) * 9 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 7, 1 ) ) * 8 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 8, 1 ) ) * 7 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 9, 1 ) ) * 6 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 10, 1 ) ) * 5 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 11, 1 ) ) * 4 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 12, 1 ) ) * 3 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 13, 1 ) ) * 2 )
), 11
) <= 1
, VALUE( MID( CPF_ou_CNPJ__c , 14, 1 ) ) != 0
)
, AND(MOD((
( VALUE( MID( CPF_ou_CNPJ__c , 1, 1 ) ) * 6 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 2, 1 ) ) * 5 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 3, 1 ) ) * 4 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 4, 1 ) ) * 3 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 5, 1 ) ) * 2 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 6, 1 ) ) * 9 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 7, 1 ) ) * 8 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 8, 1 ) ) * 7 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 9, 1 ) ) * 6 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 10, 1 ) ) * 5 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 11, 1 ) ) * 4 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 12, 1 ) ) * 3 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 13, 1 ) ) * 2 ))
, 11 ) > 1
, ( 11 - MOD((
( VALUE( MID( CPF_ou_CNPJ__c , 1, 1 ) ) * 6 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 2, 1 ) ) * 5 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 3, 1 ) ) * 4 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 4, 1 ) ) * 3 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 5, 1 ) ) * 2 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 6, 1 ) ) * 9 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 7, 1 ) ) * 8 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 8, 1 ) ) * 7 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 9, 1 ) ) * 6 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 10, 1 ) ) * 5 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 11, 1 ) ) * 4 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 12, 1 ) ) * 3 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 13, 1 ) ) * 2 )
)
, 11
) ) != VALUE( MID( CPF_ou_CNPJ__c , 14, 1 ))
)), false)
IF( LEN(CPF_ou_CNPJ__c)= 14 , OR(AND(MOD((
( VALUE( MID( CPF_ou_CNPJ__c , 1, 1 ) ) * 6 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 2, 1 ) ) * 5 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 3, 1 ) ) * 4 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 4, 1 ) ) * 3 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 5, 1 ) ) * 2 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 6, 1 ) ) * 9 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 7, 1 ) ) * 8 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 8, 1 ) ) * 7 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 9, 1 ) ) * 6 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 10, 1 ) ) * 5 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 11, 1 ) ) * 4 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 12, 1 ) ) * 3 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 13, 1 ) ) * 2 )
), 11
) <= 1
, VALUE( MID( CPF_ou_CNPJ__c , 14, 1 ) ) != 0
)
, AND(MOD((
( VALUE( MID( CPF_ou_CNPJ__c , 1, 1 ) ) * 6 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 2, 1 ) ) * 5 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 3, 1 ) ) * 4 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 4, 1 ) ) * 3 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 5, 1 ) ) * 2 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 6, 1 ) ) * 9 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 7, 1 ) ) * 8 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 8, 1 ) ) * 7 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 9, 1 ) ) * 6 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 10, 1 ) ) * 5 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 11, 1 ) ) * 4 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 12, 1 ) ) * 3 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 13, 1 ) ) * 2 ))
, 11 ) > 1
, ( 11 - MOD((
( VALUE( MID( CPF_ou_CNPJ__c , 1, 1 ) ) * 6 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 2, 1 ) ) * 5 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 3, 1 ) ) * 4 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 4, 1 ) ) * 3 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 5, 1 ) ) * 2 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 6, 1 ) ) * 9 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 7, 1 ) ) * 8 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 8, 1 ) ) * 7 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 9, 1 ) ) * 6 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 10, 1 ) ) * 5 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 11, 1 ) ) * 4 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 12, 1 ) ) * 3 ) +
( VALUE( MID( CPF_ou_CNPJ__c , 13, 1 ) ) * 2 )
)
, 11
) ) != VALUE( MID( CPF_ou_CNPJ__c , 14, 1 ))
)), false)
IF(LEN(CPF_ou_CNPJ__c)=14,OR(AND(MOD((
(VALUE(MID(CPF_ou_CNPJ__c,1,1))*6)+
(VALUE(MID(CPF_ou_CNPJ__c,2,1))*5)+
(VALUE(MID(CPF_ou_CNPJ__c,3,1))*4)+
(VALUE(MID(CPF_ou_CNPJ__c,4,1))*3)+
(VALUE(MID(CPF_ou_CNPJ__c,5,1))*2)+
(VALUE(MID(CPF_ou_CNPJ__c,6,1))*9)+
(VALUE(MID(CPF_ou_CNPJ__c,7,1))*8)+
(VALUE(MID(CPF_ou_CNPJ__c,8,1))*7)+
(VALUE(MID(CPF_ou_CNPJ__c,9,1))*6)+
(VALUE(MID(CPF_ou_CNPJ__c,10,1))*5)+
(VALUE(MID(CPF_ou_CNPJ__c,11,1))*4)+
(VALUE(MID(CPF_ou_CNPJ__c,12,1))*3)+
(VALUE(MID(CPF_ou_CNPJ__c,13,1))*2))
,11)<=1
,VALUE(MID(CPF_ou_CNPJ__c,14,1))!=0)
,AND(MOD((
(VALUE(MID(CPF_ou_CNPJ__c,1,1))*6)+
(VALUE(MID(CPF_ou_CNPJ__c,2,1))*5)+
(VALUE(MID(CPF_ou_CNPJ__c,3,1))*4)+
(VALUE(MID(CPF_ou_CNPJ__c,4,1))*3)+
(VALUE(MID(CPF_ou_CNPJ__c,5,1))*2)+
(VALUE(MID(CPF_ou_CNPJ__c,6,1))*9)+
(VALUE(MID(CPF_ou_CNPJ__c,7,1))*8)+
(VALUE(MID(CPF_ou_CNPJ__c,8,1))*7)+
(VALUE(MID(CPF_ou_CNPJ__c,9,1))*6)+
(VALUE(MID(CPF_ou_CNPJ__c,10,1))*5)+
(VALUE(MID(CPF_ou_CNPJ__c,11,1))*4)+
(VALUE(MID(CPF_ou_CNPJ__c,12,1))*3)+
(VALUE(MID(CPF_ou_CNPJ__c,13,1))*2))
,11)>1
,(11-MOD((
(VALUE(MID(CPF_ou_CNPJ__c,1,1))*6)+
(VALUE(MID(CPF_ou_CNPJ__c,2,1))*5)+
(VALUE(MID(CPF_ou_CNPJ__c,3,1))*4)+
(VALUE(MID(CPF_ou_CNPJ__c,4,1))*3)+
(VALUE(MID(CPF_ou_CNPJ__c,5,1))*2)+
(VALUE(MID(CPF_ou_CNPJ__c,6,1))*9)+
(VALUE(MID(CPF_ou_CNPJ__c,7,1))*8)+
(VALUE(MID(CPF_ou_CNPJ__c,8,1))*7)+
(VALUE(MID(CPF_ou_CNPJ__c,9,1))*6)+
(VALUE(MID(CPF_ou_CNPJ__c,10,1))*5)+
(VALUE(MID(CPF_ou_CNPJ__c,11,1))*4)+
(VALUE(MID(CPF_ou_CNPJ__c,12,1))*3)+
(VALUE(MID(CPF_ou_CNPJ__c,13,1))*2)
),11
))!=VALUE(MID(CPF_ou_CNPJ__c,14,1)))),false)
Valida Tamanho CPF ou CNPJ:
AND( NOT(ISBLANK(CPF_ou_CNPJ__c)), AND(NOT(LEN(CPF_ou_CNPJ__c)=11), NOT(LEN(CPF_ou_CNPJ__c)=14) ))
Será que há uma maneira de fazer um loop nas regras de vaildação para simplificar esse código? Se alguém souber, posta, por favor.
Is there any way to write a loop in validation rule so it could be more simple?
Thx
Is there any way to write a loop in validation rule so it could be more simple? the number has 14 digits, and the last 2 are the checksum.
Another_fomula__c=
Your final formula is:
Thx
Thx
What is the logic for last one?
Thx.
Otherwise, as a common practice, if your question is answered, please choose 1 best answer.
But you can give every answer a thumb up if that answer is helpful to you.
This will help keep the forum clean and help future users determine what answers are useful
and what answer was the best in resolving the user's issue.
Thanks
Obrigado
Hi @ brunol11. I'm a novice user. I also had the same question as the friend above. These 3 formulas are put together ???? 1st Part, 2nd Part and the validation formula if it is cpf or cnpj ???? If they are separated as it would be .... I need to validate and I can't ...
Thanks
www jacklistens com