I am trying to hijack the role assignment for watch, todo, forms and actions.
For watch and todo, this is relatively easy. I assign my dynamic role to the stage which then calls a server side script. This script knows the current process context so we can tell what stage we are at to dynamically assign a user to a stage whether that be in the watch or todo list.
However, in the case of forms or actions, as far as I can tell, there is no way to determine what form or action is checking its role within the server script.
Is there something in the metastorm object model that will allow me to do this?
My example is for a user stage with two forms and two actions:
- To do list = dyTodoList
- Watch list = dyWatchList
- Form 1 (restrict viewing to) = dyFormView
- Form 2 (restrict viewing to) = dyFormView
- Action 1 (available to roles) = dyActionUser
- Action 2 (available to roles) = dyActionUser
Role formulas:
- dyTodoList = Metastorm.Runtime.Models.MyProject.RoleAssignment.Assign(Metastorm.Runtime.Models.MyProject.RoleAssignment.RoleType.TodoList)
- dyWatchList = Metastorm.Runtime.Models.MyProject.RoleAssignment.Assign(Metastorm.Runtime.Models.MyProject.RoleAssignment.RoleType.WatchList)
- dyFormView = Metastorm.Runtime.Models.MyProject.RoleAssignment.Assign(Metastorm.Runtime.Models.MyProject.RoleAssignment.RoleType.FormView)
- dyActionUser = Metastorm.Runtime.Models.MyProject.RoleAssignment.Assign(Metastorm.Runtime.Models.MyProject.RoleAssignment.RoleType.ActionUser)
Rule formula script:
...
public class RoleAssignment {
public enum RoleType { ActionUser = 1, FormView = 2, TodoList = 4, WatchList = 8 };
public static List Assign(RoleType roleType) {
List users = new List();
ProcessContext processContext = new ProcessContext();
// Todo list or watch list items, determine the stage and return users relevant to that stage
if ((roleType == RoleType.TodoList) || (roleType == RoleType.WatchList)) {
if (processContext.StageName == "Stage1") { users.Append(new string[] { "User1", "User2" } ); }
if (processContext.StageName == "Stage2") { users.Append(new string[] { "User3", "User4" } ); }
}
// List of users available to the action that is being checked
if (roleType == RoleType.ActionUser) {
// ? What action is currently checking its role ?
if (action.actionname == "action1") { users.Append(new string[] { "User5", "User6" } ); }
if (action.actionname == "action2") { users.Append(new string[] { "User7", "User8" } ); }
}
// List of users able to see the form that is being checked
if (roleType == RoleType.FormView) {
// ? What action is currently checking its role ?
if (form.formname == "form1") { users.Append(new string[] { "User9", "UserA" } ); }
if (form.formname == "form2") { users.Append(new string[] { "UserB", "UserC" } ); }
}
return users;
}
}
...
If I were able to determine the form or action name within this server script, I can then create a script that can dynamically assign users to specific stages, forms and actions without having to make changes to a project or having to deploy a new solution.
Adding some logging code to the above does indeed show that the script is called a total of 6 times when entering a stage. So that kind of confirms the process that is taking place.
I could leave the forms and actions available to 'everyone' and enter some specific code in the 'restrict viewing to' / 'only show action if' that sends through the action / form name with each call. However, this would be a bit clunky and mean development overhead.
Ultimately, I am hoping that someone out there knows where in the object model I can get the information I need to move forward.
Any suggestions gratefully accepted.
Nils.