cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
691
Views
0
Helpful
5
Replies

CCX Script to validate Customer id

dsobrinho
Level 9
Level 9

Hi team,

 

A customer asked me to create a ccx script to contain an ID verification step. He didn't want a database query, just a document validator through a numerical verification algorithm.

 

Does anybody know something like that? An example how to start maybe.

Daniel Sobrinho
5 Replies 5

You can do this with regex and a little bit of Java. I have a phone number validator function somewhere that I'll post once I find it.

 

david

Hi @david.macias 

 

Could you help with this step:

Using regex :
Step1:  [0-9]{3}\.?[0-9]{3}\.?[0-9]{3}\-?[0-9]{2}

or

Step2: ^(((\d{3}).(\d{3}).(\d{3})-(\d{2}))?((\d{2}).(\d{3}).(\d{3})/(\d{4})-(\d{2}))?)*$

or


Step3: via  Javascript:

function validaCPF(cpf) {
  var Soma = 0
  var Resto

  var strCPF = String(cpf).replace(/[^\d]/g, '')
  
  if (strCPF.length !== 11)
     return false
  
  if ([
    '00000000000',
    '11111111111',
    '22222222222',
    '33333333333',
    '44444444444',
    '55555555555',
    '66666666666',
    '77777777777',
    '88888888888',
    '99999999999',
    ].indexOf(strCPF) !== -1)
    return false

  for (i=1; i<=9; i++)
    Soma = Soma + parseInt(strCPF.substring(i-1, i)) * (11 - i);

  Resto = (Soma * 10) % 11

  if ((Resto == 10) || (Resto == 11)) 
    Resto = 0

  if (Resto != parseInt(strCPF.substring(9, 10)) )
    return false

  Soma = 0

  for (i = 1; i <= 10; i++)
    Soma = Soma + parseInt(strCPF.substring(i-1, i)) * (12 - i)

  Resto = (Soma * 10) % 11

  if ((Resto == 10) || (Resto == 11)) 
    Resto = 0

  if (Resto != parseInt(strCPF.substring(10, 11) ) )
    return false

  return true
}

 

Daniel Sobrinho

There was a similar  thread I just replied to, why don't you put the IDs in an XML file? That's probably your best, easiest to manage process and it doesn't require any custom Java.

 

david

Hello David, 

 

Can you show how i can do this?

 

Best Regards.

There are a lot of links out there on how to do this, here's one that could help. https://community.cisco.com/t5/contact-center/uccx-12-0-zip-code-xml-file-lookup/td-p/3937509

david