1
0
-1

With the following script, I am able to get the requestor name but I am unable to get for the department. I though just changing the hash variable "#currentUser.username#" to  "#user.username.department.name#" will get me the department.

import org.joget.apps.form.model.*;
import org.joget.apps.form.service.*;
import java.sql.*;
import org.apache.commons.collections.SequencedHashMap;
import java.util.*;

public FormRowSet test() {
FormRowSet f = new FormRowSet();
f.setMultiRow(true);
FormRow r1 = new FormRow();
r1.put("requestorUserName", "#currentUser.username#");
f.add(r1);
return f;
}

return test();

    CommentAdd your comment...

    1 answer

    1.  
      1
      0
      -1

      Hi,

      If you want the current user's data, use Hash Variable#CurrentUserHashVariable 

      If you want other users, use Hash Variable#UserHashVariable

      Have you tried #currentUser.department.name#?

      1. Aaron Tan

        Good day,

        Yes, I have tried the hash, #currentUser.department.name# before posting. I will get the info as shown below


      2. Ian

        Ah i see, #currentUser.department.name# is only available for enterprise edition. Since you're using community edition, you'll probably need to perform a SQL query to get the department name.

        Something like :

        SELECT name FROM dir_department d INNER JOIN dir_employment e ON d.organizationId = e.organizationId WHERE e.userId = #currentUser.username#

      3. Aaron Tan

        Oh no wonder, I though the enterprise edition only apply for the below attribute. Anyway, thank you for taking your time to clarified on this matter.

      CommentAdd your comment...