Check The User Is In The Organization
If the specified User is the leader of the specified Organization this task returns “L”. If they are one of the its members it returns “M”. If the User doesn’t belong to the Organization it returns nothing.
2017 (C) Questetra, Inc. (MIT License)
Configs
  • A: Set OAuth2 Config Name (at [OAuth 2.0 Setting]) *
  • A2: Set Application-Root URI ( https:// … ) * #{EL}
  • B: Select STRING/CHECKBOX DATA for Qrole Id (Role Id) *
  • C: Select STRING/USER DATA for Quser Email *
  • X: Select STRING DATA for Access Log (update)
Script
main();
function main(){
  //set group data from I2
  var groupIs = engine.findDataByNumber(configs.get("groupField"));
  //set user data from I2
  var userIs = engine.findDataByNumber(configs.get("userField"));
  //Error
  errorCheck(groupIs,userIs);
  var result = "";
  if (check(true,userIs,groupIs)) {
    result = "L";
  }else if (check(false,userIs,groupIs)) {
    result = "M";
  }
  //set result to O1
  engine.setDataByNumber(configs.get("result"),result);
}
//check whether the user is the leader or a staff member of the group
function check(LM,user,group){
  var temp;
  var list = quserDao.findByQgroupAndPosition(group,LM);
  for (var i = 0;i<list.size();i++){
    temp = list.get(i);
    if(user.getId().equals(temp.getId())){
      return true;
    }
  }
}
function errorCheck(group,user){
  if (group == null && user != null) {
    throw "Organization Not Selected";
  }else if (group != null && user == null) {
    throw "User Not Selected";
  }else if (group == null && user == null){
    throw "Organization and User Not Selected";
  }
  var userC = quserDao.findById(user.getId());
  var groupC = qgroupDao.findById(group.getId());
  if (userC == null && groupC != null) {
    throw "Selected user doesn't exist";
  }else if (userC != null && groupC == null) {
    throw "Selected Organization doesn't exist";
  }else if (userC == null && groupC == null){
    throw "Selected Organization and User don't exist";
  }
}

Download

Capture

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: