ISO 6346 algorithm - Client Script

ISO 6346 algorithm - Client Script

ISO 6346 is an international standard covering the coding, identification and marking of intermodal (shipping) containers.

Friend how are you? could you help me with this? I have a workflow and an associated function that work without a problem, in this function I check that the container number is correct, if it is, the workflow adds a check in a checkbox field.

I have taken this code that works correctly and try to run it as a client script, I have been unsuccessful for a few days. If you could help me it would be great.

  1. var Name = value;
    if (Name !== null) {
        if (Name.length === 11) {
            var first10 = [];
            var isOk = false;
            var check = -1;
            var char2num = new Map({"0":0,"1":1,"2":2,"3":3,"4":4,"5":5,"6":6,"7":7,"8":8,"9":9,"A":10,"B":12,"C":13,"D":14,"E":15,"F":16,"G":17,"H":18,"I":19,"J":20,"K":21,"L":23,"M":24,"N":25,"O":26,"P":27,"Q":28,"R":29,"S":30,"T":31,"U":32,"V":34,"W":35,"X":36,"Y":37,"Z":38});
            if(cntrNum.length === 11){
                cntrNum = cntrNum.toUpperCase();
                first10.push(cntrNum.substring(0,1));
                first10.push(cntrNum.substring(1,2));
                first10.push(cntrNum.substring(2,3));
                first10.push(cntrNum.substring(3,4));
                first10.push(cntrNum.substring(4,5));
                first10.push(cntrNum.substring(5,6));
                first10.push(cntrNum.substring(6,7));
                first10.push(cntrNum.substring(7,8));
                first10.push(cntrNum.substring(8,9));
                first10.push(cntrNum.substring(9,10));
                check = parseInt(cntrNum.substring(10,11));
                var num = 0.0;
                var x = 0;
                for(var c of first10){
                    var val = char2num.get(c);
                    var producto = Math.pow(2,x);
                    var sum = val * producto;
                    num = num + sum;
                    x = x + 1;
                }
                num = num - (Math.floor(num / 11) * 11);
                var mayor = num > 9;
                if(mayor){
                    var numString = num.toString().substring(1,2);
                    num = parseFloat(numString);
                }
                if(check !== num){
                    ZDK.Client.showConfirmation('El numero de contenedor no cumple norma ISO 6346','Continuar','Corregir');
                }
            }
        }
    }
Information
Page Details
Category
Module
Page
Create Page
Module
Contenedores
Layout
Estándar
Event Details
Event Type
Field Event
Field
Contenedor
Event
onChange
Library
ZDK
ZDK-1.0
CRM API
2.0