Assign a role to all users

Hello all,

Is there a way to easily assign a new role to ALL users?

We have a situation in which we have 1300 users and we have to add a specific role to ALL.

Thanks a lot

Parents
  • Ciao ,

    I don't think there is a way to do this "easily".

    The only thing I can think of is to write a script that will loop through your users records and for each one add the known role_id.

    You can do this using the bean if working within the Sugar framework (perhaps with a one-off custom Scheduler):

      $link = 'aclroles';
      if($userBean->load_relationship($link)){
        $userBean->$link->add($role_id);
      }

    You can use SugarQuery to get the user ids, and to get the role_id by name if you don't want to hard-code the role_id.

    You could also add a relationship using a POST /Users/:record/link/aclroles/:role_id if you want to do this from outside Sugar.

    In bocca al lupo,

    FrancescaS

Reply
  • Ciao ,

    I don't think there is a way to do this "easily".

    The only thing I can think of is to write a script that will loop through your users records and for each one add the known role_id.

    You can do this using the bean if working within the Sugar framework (perhaps with a one-off custom Scheduler):

      $link = 'aclroles';
      if($userBean->load_relationship($link)){
        $userBean->$link->add($role_id);
      }

    You can use SugarQuery to get the user ids, and to get the role_id by name if you don't want to hard-code the role_id.

    You could also add a relationship using a POST /Users/:record/link/aclroles/:role_id if you want to do this from outside Sugar.

    In bocca al lupo,

    FrancescaS

Children