Brazilian CPF Field Number

Diego Cañete July 26, 2019

Hi all,
I am needing help to be able to create a ticket creation form with a numeric field that allows me to load the Brazilian document number with this format:
 000.000.000-00 and that the validation does not error when the user loads this value, any suggestions? with dots and dashes.

The other thing is that it cannot be repeated, I have to verify that the value of the field is unique in each case, it cannot be repeated when the end user loads another ticket.

Someone who can urinate me how to do this?

Thank you so much.

Diego.

image.pngimage.png

2 answers

2 accepted

0 votes
Answer accepted
Alexey Ershov July 27, 2019

Unfortunately, I do not know how to verify the uniqueness of a field without using third-party tools.
It's look like, you can try to use this free plugin:
Unique Regex Custom Field
It must do all what you need.

Another option try to write your own plugin for validation Creating workflow extensions.

Diego Cañete August 26, 2019

here is the boolean expresion for check duplicate field value:

 

Only if the following boolean expression is true: count(filterByValue(fieldValue(%{field_number}, filterByIssueType(getIssuesFromProjects("project_name"), "issue_name" ) ) , =, %{field_number})) = 0

 

Is a Validator in when "Create" for example.

 

Greetins 

Diego-

0 votes
Answer accepted
Alexey Ershov July 26, 2019

Hello.

First of all i think you need not numberic, but text field.
Second you need write Regex Validator to verify, the entered value corresponds to format what you need.
Set description for your custom field like "enter CPF № in 000.000.000-00 format"
You can use standart Workflow 'Regular Expression Check' Validator to Restrict Text Field in Number Format, and set validator to: ^[0-9]{3}\.[0-9]{3}\.[0-9]{3}-[0-9]{2}$
Using Workflow 'Regular Expression Check' Validator to Restrict Text Field in Number Format
But in this case jira show useless error message for user, in case if entered value wrong like: "Field CPF with actual value 000x000.000-00 does not match regular expression ^[0-9]{3}\.[0-9]{3}\.[0-9]{3}-[0-9]{2}$"

CPF.png
Another good option try to use Validation based on regular expression and sctipt plugin like power script from cprime. Validation based on regular expression
With power script you also can actually check if any other issue exist with same value, using jql search for this.

UPD

Unfortunately, I do not know how to verify the uniqueness of a field without using third-party tools.
It's look like, you can try to use this free plugin:
Unique Regex Custom Field
It must do all what you need.

Another option try to write your own plugin for validation Creating workflow extensions.

Alex

Diego Cañete July 26, 2019

Hi Alex,

Thank you for your prompt and successful response.
Apparently your sulfation works well, how can I not put a value that is already used? Does the CPF field be unique for each ticket?

Diego Cañete July 26, 2019

Because this value is an identification number "ID"

Diego Cañete July 26, 2019

Adding this Java Scrip as validation is possible?

https://www.geradorcpf.com/javascript-validar-cpf.htm

function validarCPF(cpf) { 
 cpf = cpf.replace(/[^\d]+/g,''); 
 if(cpf == '') return false; 
 // Elimina CPFs invalidos conhecidos 
 if (cpf.length != 11 || 
  cpf == "00000000000" || 
  cpf == "11111111111" || 
  cpf == "22222222222" || 
  cpf == "33333333333" || 
  cpf == "44444444444" || 
  cpf == "55555555555" || 
  cpf == "66666666666" || 
  cpf == "77777777777" || 
  cpf == "88888888888" || 
  cpf == "99999999999")
   return false;  
 // Valida 1o digito 
 add = 0; 
 for (i=0; i < 9; i ++)  
  add += parseInt(cpf.charAt(i)) * (10 - i); 
  rev = 11 - (add % 11); 
  if (rev == 10 || rev == 11)  
   rev = 0; 
  if (rev != parseInt(cpf.charAt(9)))  
   return false;  
 // Valida 2o digito 
 add = 0; 
 for (i = 0; i < 10; i ++)  
  add += parseInt(cpf.charAt(i)) * (11 - i); 
 rev = 11 - (add % 11); 
 if (rev == 10 || rev == 11) 
  rev = 0; 
 if (rev != parseInt(cpf.charAt(10)))
  return false;  
 return true;   
}
Diego Cañete July 26, 2019

Ok, I use the first answer, Jira's plug-ins are all too expensive for our country. So much of not using addons.

Thanks for your answer.

 

For the purpose of validating that it is still unique, is there no way to do it without installing a plug-in?

Suggest an answer

Log in or Sign up to answer