Difference between revisions of "Repositorio de Custom Commands"
From GXtest Wiki
Line 1: | Line 1: | ||
+ | == Generar CNPJ == | ||
+ | '''Tipo''': Acción <br> | ||
+ | '''Descripción''': no tiene parametros (salida en variable &_resultcc) | ||
+ | |||
+ | <pre> | ||
+ | var n = 9; | ||
+ | var n1 = Math.round(Math.random()*n); | ||
+ | var n2 = Math.round(Math.random()*n); | ||
+ | var n3 = Math.round(Math.random()*n); | ||
+ | var n4 = Math.round(Math.random()*n); | ||
+ | var n5 = Math.round(Math.random()*n); | ||
+ | var n6 = Math.round(Math.random()*n); | ||
+ | var n7 = Math.round(Math.random()*n); | ||
+ | var n8 = Math.round(Math.random()*n); | ||
+ | var n9 = 0; | ||
+ | var n10 = 0; | ||
+ | var n11 = 0; | ||
+ | var n12 = 1; | ||
+ | var d1 = n12*2+n11*3+n10*4+n9*5+n8*6+n7*7+n6*8+n5*9+n4*2+n3*3+n2*4+n1*5; | ||
+ | d1 = 11 - ( Math.round(d1 - (Math.floor(d1/11)*11)) ); | ||
+ | if (d1>=10) d1 = 0; | ||
+ | var d2 = d1*2+n12*3+n11*4+n10*5+n9*6+n8*7+n7*8+n6*9+n5*2+n4*3+n3*4+n2*5+n1*6; | ||
+ | d2 = 11 - ( Math.round(d2 - (Math.floor(d2/11)*11)) ); | ||
+ | if (d2>=10) d2 = 0; | ||
+ | retorno = ''+n1+n2+n3+n4+n5+n6+n7+n8+n9+n10+n11+n12+d1+d2; | ||
+ | return retorno; | ||
+ | |||
+ | </pre> | ||
+ | |||
+ | |||
+ | |||
== Generar CPF == | == Generar CPF == | ||
'''Tipo''': Acción <br> | '''Tipo''': Acción <br> |
Revision as of 14:32, 8 March 2013
Contents |
Generar CNPJ
Tipo: Acción
Descripción: no tiene parametros (salida en variable &_resultcc)
var n = 9; var n1 = Math.round(Math.random()*n); var n2 = Math.round(Math.random()*n); var n3 = Math.round(Math.random()*n); var n4 = Math.round(Math.random()*n); var n5 = Math.round(Math.random()*n); var n6 = Math.round(Math.random()*n); var n7 = Math.round(Math.random()*n); var n8 = Math.round(Math.random()*n); var n9 = 0; var n10 = 0; var n11 = 0; var n12 = 1; var d1 = n12*2+n11*3+n10*4+n9*5+n8*6+n7*7+n6*8+n5*9+n4*2+n3*3+n2*4+n1*5; d1 = 11 - ( Math.round(d1 - (Math.floor(d1/11)*11)) ); if (d1>=10) d1 = 0; var d2 = d1*2+n12*3+n11*4+n10*5+n9*6+n8*7+n7*8+n6*9+n5*2+n4*3+n3*4+n2*5+n1*6; d2 = 11 - ( Math.round(d2 - (Math.floor(d2/11)*11)) ); if (d2>=10) d2 = 0; retorno = ''+n1+n2+n3+n4+n5+n6+n7+n8+n9+n10+n11+n12+d1+d2; return retorno;
Generar CPF
Tipo: Acción
Descripción: no tiene parametros (salida en variable &_resultcc)
var n = 9; var n1 = Math.round(Math.random()*n); var n2 = Math.round(Math.random()*n); var n3 = Math.round(Math.random()*n); var n4 = Math.round(Math.random()*n); var n5 = Math.round(Math.random()*n); var n6 = Math.round(Math.random()*n); var n7 = Math.round(Math.random()*n); var n8 = Math.round(Math.random()*n); var n9 = Math.round(Math.random()*n); var d1 = n9*2+n8*3+n7*4+n6*5+n5*6+n4*7+n3*8+n2*9+n1*10; d1 = 11 - ( Math.round(d1 - (Math.floor(d1/11)*11)) ); if (d1>=10) d1 = 0; var d2 = d1*2+n9*3+n8*4+n7*5+n6*6+n5*7+n4*8+n3*9+n2*10+n1*11; d2 = 11 - ( Math.round(d2 - (Math.floor(d2/11)*11)) ); if (d2>=10) d2 = 0; retorno = ''+n1+n2+n3+n4+n5+n6+n7+n8+n9+d1+d2; return retorno;
Go To Object
Tipo: Evento
Descripción: se pasa por parámetro un nombre de un objeto GeneXus y navega a la url de dicho objeto.
if (currentLanguage=="java") { window.location=paramJS; } else if (currentLanguage=="net") { window.location=paramJS+".aspx"; } else { window.alert("language: " + currentLanguage); } result = "OK"; return result;
VerifyUrl
Tipo: Validacion
Descripción: se pasa por parámetro una url y valida que la url del browser coincida con dicha url
var url=window.document.location.href; if(url.indexOf(paramJS)==-1) result = "OK"; else result="falla";
VerifyTitle
Tipo: Validacion
Descripción: se pasa por parámetro un titulo y valida que el titulo del browser coincida con el pasado como parámetro.
if (document.location.href.indexOf(paramJS)!=-1) { result = "OK"; } else { result= "The string ("+paramJS+") is not in the url ("+document.location.href+")"; }
ClickGridButtons
Tipo: Acción
Descripción: Hace click en el paginado automático de una grid de Evolution, se pasa por parámetro "First", "Previous", "Next" o "Last".
function CustomCommand (paramJS, currentGXVersion, currentLanguage) { windows.document.getElementsByClassName("PagingButtons" + paramJS)[0].click(); result = "OK"; return result; }