Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

    • An org.joget.apps.form.model.FormRowSet object which contains one or more org.joget.apps.form.model.FormRow object. All FormRow objects are expected to have "value" and "label" property.

Samples:

Load user as options based on the group id passed by the controlling field.

Code Block
languagejava
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 = null;
    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());
        rows.add(option);
    }
    
    return rows;
}

//call load method with injected variable
return load(values);

Use as Form Store Binder

Injected Variables:

...