Roles inside of applications

  • yannick
        Has successfully completed the online course Advanced (300)
      5 years ago #13058

      Hi,

      Is it possible to execute processes based on user roles?

      Chris Bouveret
          Has successfully completed the online course Introduction
          Has successfully completed the online course Intermediate (200)
          Has successfully completed the online course Advanced (300)
          Has successfully completed the online course Basics (100)
          Has successfully completed the online course Advanced (320)
          Has successfully completed the Intermediate Certification
          Has successfully completed the Advanced Certification
        5 years ago #13065
        Up
        1
        Down
        ::

        Hi Yannick,

        yes, this is possible. We provide a Business Object “User” for accessing Roles and User Attributes (see attached Screenshot). You can use it to get the Role of a looged in User and with a Condition Activity within Process Designer you can react on different Roles of Users. Hope this helps, if you have further questions please let me know.

        Attachments:
        You must be logged in to view attached files.
        Christopher Steinbach
            5 years ago #15625
            Up
            0
            Down
            ::

            Hi Chris,

            I would like to have such a BO. How do you provide it? A link to a repo would be nice.

            Why is such a functionality not already included as server action? Such a functionality is mandatory in many applications.

            I’ve also noticed that the API documentation for the USERS object is missing in the Simplifier documentation. I’m guessing that the User_BO is built on that Object?!

            Chris Bouveret
                Has successfully completed the online course Introduction
                Has successfully completed the online course Intermediate (200)
                Has successfully completed the online course Advanced (300)
                Has successfully completed the online course Basics (100)
                Has successfully completed the online course Advanced (320)
                Has successfully completed the Intermediate Certification
                Has successfully completed the Advanced Certification
              5 years ago #15632
              Up
              0
              Down
              ::

              Hi there,

              you can create a new BusinessObject with the following Method: getCurrentUserRole and this code:

              var user = Simplifier.User.getCurrentUser();
              output.hasRole = false;
              if(user.roles) {
                  if(user.roles.length) {
                      Simplifier.Log.info("Roles", JSON.stringify(user.roles));
                      for (var i = user.roles.length - 1; i >= 0; i--) {
                          if(user.roles[i].name === input.roleName) {
                              output.hasRole = true;
                              break;
                          }
                      }
                  } else {
                      throw new Error("User has no Roles");
                  }
              } else {
                  throw new Error("User has no Roles");
              }

              this code uses the input Parameter “roleName” as String and returns the output “hasRole” as boolean (true/false)

              It is based on the Simplifier BusinessObject Server API documented here

              Hope that helps

              Christopher Steinbach
                  5 years ago #15691
                  Up
                  0
                  Down
                  ::

                  Thank you, that helps a lot.

                Viewing 5 posts - 1 through 5 (of 5 total)

                You must be logged in to reply to this topic.