Calculating a Role from Another Role

Options

I have a dynamic role whose members will be based on a condition; if the condition is true, the members will come from another role (defined in a library that I have, but that's not important); if the condition is false, there will be no members.  So I'm trying to accomplish this in the role formula using a ternary "if" statement, but I'm not able to get access the role in a way that the compiler will let me.  For example, here is my current formula:

 

MyProcessData.IsManagerNeeded ? GeneralLibrary.Roles.DepartmentManagers : String.Empty

 

The compiler is complaining: "...DepartmentManagers is a 'type', which is not valid in the given context".  The "DepartmentManagers" class does not appear to have any methods or properties that return a List so I can convert it to a string.

 

Any help would be appreciated.

 

-Rory

Tagged:

Comments

  • I'm pretty sure you need to return a list as it is the Roles are expecting this as a return value.

     

    If your class does not return a list but a string (like mine - comma deleminted), then convert the string to a List.

     

    So, General.Roles.DepartmentMangers would need to be split as an array first - like...

    string[] userList = General.Roles.DepartmentMangers.Split(',');

     

    To convert the array to a list - List.Convert(userList);

     

    I guess the question to you is what type (list, array, string, etc) is DepartmentManagers? Then try to convert that type to a List.

     

  • You are now a 'semi-colonist', I'm afraid.

     

    This is a class. The class itself has no members, but an object does. You could try (but I have not tested):

     

    MyProcessData.IsManagerNeeded ? new GeneralLibrary.Roles.DepartmentManagers().UserAccess() : ListItems()
    
  • You could also try the 'only show action if' property for actions - that may be easier. There is no equivalent for stages, however.

  • Hmmm, this seems like a reasonable approach.  Unfortunately, when I try to deploy, I'm getting an error "The type or namespace name 'Roles' does not exist in the namespace 'Metastorm.Runtime.Models.GeneralLibrary' (are you missing an assembly reference?)".  This error doesn't show up if I just validate...validation succeeds.

  • If it's not clear, I was referring to your first post Jerome҉

  • Is it possible that you are missing a referenced DLL in your deploy/customlib (or is it dotnetlib) folder?  make sure the DLL's match in that folder and your designer/customlib folder.

  • I can't find any folder "deploy/customlib", but my "designer/customlib" folder has three DLL's: Metastorm.Dms.dll, Metastorm.Dms.SharePoint.dll, and System.configuration.dll.

  • I don't see a ListItems object within the designer member list...  Maybe that is the unreferenced object.  Try

     

    List l = List.Convert(new Roles.YourRole().UserAccess());

  • MyProcessData.IsManagerNeeded ? List.Convert(new GeneralLibrary.Roles.DepartmentManagers().UserAcce​ss()) : List.Convert("")

    Updated... these Role classes are a cool feature - never knew that you could use them in this way (if it works)

  • Mike, none of this is working. According to the error message, it can't find the namespace "Roles".