Java code to CNPJ validation

Hey, Guys!

I have a problem to do a validation on CNPJ. This error is happened when I used the code.
The recurrent problem is on photo, but when I repair at line the same problem appear at other line

Above my code:

substring($column1$, 0, 2) + “.” +
substring($column1$, 2, 3) + “.” +
substring($column1$, 5, 3) + “/” +
substring($column1$, 8, 4) + “-” +
substring($column1$, 12, 2) as CNPJ,
(
(
(
(
(toInt(substring($column1$, 0, 1)) * 5) +
(toInt(substring($column1$, 1, 1)) * 4) +
(toInt(substring($column1$, 2, 1)) * 3) +
(toInt(substring($column1$, 3, 1)) * 2) +
(toInt(substring($column1$, 4, 1)) * 9) +
(toInt(substring($column1$, 5, 1)) * 8) +
(toInt(substring($column1$, 6, 1)) * 7) +
(toInt(substring($column1$, 7, 1)) * 6) +
(toInt(substring($column1$, 8, 1)) * 5) +
(toInt(substring($column1$, 9, 1)) * 4) +
(toInt(substring($column1$, 10, 1)) * 3) +
(toInt(substring($column1$, 11, 1)) * 2)
) % 11
) < 2 AND toInt(substring($column1$, 12, 1)) == 0
) OR (
(
(
(toInt(substring($column1$, 0, 1)) * 5) +
(toInt(substring($column1$, 1, 1)) * 4) +
(toInt(substring($column1$, 2, 1)) * 3) +
(toInt(substring($column1$, 3, 1)) * 2) +
(toInt(substring($column1$, 4, 1)) * 9) +
(toInt(substring($column1$, 5, 1)) * 8) +
(toInt(substring($column1$, 6, 1)) * 7) +
(toInt(substring($column1$, 7, 1)) * 6) +
(toInt(substring($column1$, 8, 1)) * 5) +
(toInt(substring($column1$, 9, 1)) * 4) +
(toInt(substring($column1$, 10, 1)) * 3) +
(toInt(substring($column1$, 11, 1)) * 2)
) % 11
) == (11 - toInt(substring($column1$, 12, 1)))
)
) as Valid_CNPJ

Hey Cario,

Column Expressions nodes uses syntax and grammar based on JavaScript. To use substring in Javascript, you need to use string_to_edit.substring(start, end) format. Would you mind to try it out to see if this works?

Best Regards,
Jinwei

2 Likes

Yes! Absolutelly.

Thank you!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.