1
0
-1

I want User email From The External directory 
I only Get user name and full name 
is There any option to get user email from the external directory 


    CommentAdd your comment...

    1 answer

    1.  
      1
      0
      -1

      Hi,

      -You can use "BeanShell Form Binder"

      -After setting up the user's info, you can use the BeanShell script below and modify it to your convenience.

      Script:

      import java.util.Collection;
      import org.joget.apps.app.service.AppUtil;
      import org.joget.apps.form.model.Element;
      import org.joget.apps.form.model.FormData;
      import org.joget.apps.form.model.FormRow;
      import org.joget.apps.form.model.FormRowSet;
      import org.joget.apps.form.service.FormUtil;
      import org.joget.directory.model.User;
      import org.joget.directory.model.service.ExtDirectoryManager;
       
      public FormRowSet load(String[] values) {
          FormRowSet rows = new FormRowSet();
           
          ExtDirectoryManager directoryManager = (ExtDirectoryManager) AppUtil.getApplicationContext().getBean("directoryManager");
           
          //set groupId based on dependency value
          String groupId = "G-004";
          if (values != null && values.length > 0) {
              groupId = values[0];
          }
           
          //Get users using directory manager
          Collection userList = directoryManager.getUsers(null, null, null, null, groupId, null, null, "firstName", false, null, null);
          for(Object u : userList){
              User user = (User) u;
              FormRow option = new FormRow();
              option.setProperty(FormUtil.PROPERTY_VALUE, user.getUsername());
              option.setProperty(FormUtil.PROPERTY_LABEL, user.getFirstName() + " " + user.getLastName() + " " + user.getEmail());
              rows.add(option);
          }
           
          return rows;
      }
       
      //call load method with injected variable
      return load(values);

      Output Preview:

      See Bean Shell Programming Guide#Usages for more information. Thank you

      1. Nooru

        I had copy this code on the form
        but  I don't get any user  email from the external directory 

        Thanx in advance

      2. Abdalah al Mnaez

        Check the group id for your users in the external directory. Provide that group id in the variable "String groupId = "G-004". THank you

      3. Abdalah al Mnaez

        Or set "String groupId = "null";.Thank you

      CommentAdd your comment...