JavaScript Method
Application Type
Traditional Web
Service Studio Version
11.11.15 (Build 48647)
  1. function iinCheck(iin, clientType, birthDate, sex, isResident) {

  2. //clientType: 1 -Phys. person (IIN), 2 - Jur. face (BIN)

  3. //birthDate:  ( Javascript Date)

  4. //sex: true - m, false - f

  5. //isResident: true - resident, false: non-resident (true: default)

  6. isResident = isResident || true;

  7. if(!iin) return false;

  8. if(iin.length!=12) return false;

  9. if(!(/[0-9]{12}/.test(iin))) return false;

  10. switch(clientType){

  11. case 1:

  12. //Phys.person

  13. /Checking the first facet for coincidence with the date of birth YYMMDD

  14. if(iin.substring(0, 6)!=(

  15. "" +

  16. (birthDate.getYear()) +

  17. ((birthDate.getMonth()+1)<10?"0":"")+

  18. (birthDate.getMonth()+1)+

  19. (birthDate.getDate()<10?"0":"")+

  20. birthDate.getDate())) return false;

  21. // Check gender and age of birth(century)
  22. var s = parseInt(iin.substring(6, 7));

  23. if(((s%2)==1)!=sex) return false;

  24. if(

  25. birthDate.getFullYear()<(1800+parseInt(s/2)*100)

  26. || birthDate.getFullYear()>(1900+parseInt(s/2)*100)) return false;

  27. break;


Hello!!
how to implement this method on Outsystems?

Algoritm:
This method should check the correctness of the adopted IIN. Algorithm: 12 digits, the first 6 digits are "YYMMDD", the 7th digit is responsible for the age of birth and gender. If the number is odd, the gender is male, even - female. 1,2 - nineteenth century, 3.4 - twentieth, 5.6 - twenty-first.

Champion

Hi,


You can load the function into Outsystems using these :

1. using expression with Escape Content = No

2. Put on Javascript section on Screen


After that is matter of calling the function.


Thanks

As @Toto already said in the previous answer, you just need to write your javascript code either on an expression with unescape content or in the javascript property of the screen.

Both are correct, but regarding Outsystems best pratices maybe you want to go for the second one since it will cache the JS code and you're seperating the HTML code from the JS code. Plus, if you will use this JS code in more than one screen please consider to create a web block just to encapsulate it (also on the javascript block property) and use on the screens you will need it:

 

If you will need the JS code for almost every, if not all the module screens, then save it on the Javascript module property:

Finally, if you need to run a javascript function in an action flow, use the RunJavascript action from the HttpRequestHandler extension module, and on the script of that action just call the function:



Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.