1
0
-1

I am building a string that is used for the UserID based on part of the first and last names as the form is being filled in.  This UserID needs to be unique and is entered into a field in the dir_user table as well as an application-specific table.  As the user leaves the Last name field, when the UserID is built, I need to read the dir_user table to detect a possible duplicate.  How do I access that table while executing the javascript in the Custom HTML on the form? 

The sample below is executed in the $(document).ready(function() ...

$('input[name="usersLname"]').change( function() {
if($('input[name="usersLname"]').val()!='' && $('input[name="usersFname"]').val()!='')
{
var lname=$('input[name="usersLname"]').val();
var fname=$('input[name="usersFname"]').val();
var usersIdent=lname.substring(0,4)+fname.substring(0,1)+'001';
$('input[name="usersIdent"]').val(usersIdent.toUpperCase());
$('input[name="usersLogin"]').val(usersIdent.toUpperCase());
};
});

    CommentAdd your comment...

    4 answers

    1.  
      2
      1
      0

      Hi Anders,

      Is it possible to have some custom examples of sample codes like these? I think the whole joget community would appreciate more cookbooks and sample examples. The ones that are existing are really useful but these kinds of advanced examples would be highly appreciated.

      1. Anders

        Hi, to make an AJAX call using JavaScript there are many resources online for example https://stackoverflow.com/questions/9436534/ajax-tutorial-for-post-and-get

      CommentAdd your comment...
    2.  
      2
      1
      0

      Yes ... this is client side java.  But this client side java also writes to the database.  I need to check for dups before writing to that db table.  There has to be some function that can be called to bring back a 0 or 1 (yes it's in there or no, it is not in there) ...

        CommentAdd your comment...
      1.  
        2
        1
        0

        Hi, JavaScript runs on the client-side. If you wish to read dir_user database data then you will probably need to make an AJAX call to some kind of web service at the server. Maybe JSON API#web/json/directory/admin/user/list, or using the API Builder.

          CommentAdd your comment...
        1.  
          1
          0
          -1

          The purpose for my inquiry is ... notice in my sample script, I have a suffix of 001.  If there is an existing record with the 001, I need increment by 1 until there no longer is a dup.  Then, the user can continue filling in the form.

            CommentAdd your comment...