In your code sample you are calling a method (developer.m-files.com/.../ that returns StateTransitionsForClient. You can't cast those items to a StateTransition.
I think you will need to use GetWorkflowAdmin to retrieve the workflow then get the state transitions from there.
I have pulled workflow and states just as you have specified and also I have managed to loop through states. What is the next method to call?
If you have the state transition (you said state - do you mean the transition?) then you should be able to place a breakpoint and take a look at the state transition object at that moment.
Then, looking at the original guidance, does that give you a starting point?
I have managed to figure it out and actually it works. so this is how it is supposed to work.
var workflow = vault.WorkflowOperations.GetWorkflowAdmin(107);
foreach(StateTransition stateTransition in workflow.StateTransitions)
{
if(stateTransition.FromState==137&&stateTransition.ToState==138)
{
AccessControlList acl = stateTransition.AccessControlList; // Display the ACL details
foreach (AccessControlEntry accessControlEntry1 in acl)
{
if (accessControlEntry1.IsGroup)
{
var usergroup = vault.UserGroupOperations.GetUserGroup(accessControlEntry1.UserOrGroupID);
foreach(var account in usergroup.Members)
{
var userid = vault.UserOperations.GetLoginAccountOfUser(Convert.ToInt16(account));
if (userid.EmailAddress == useremail)
{
Console.WriteLine("Can transition");
break;
}
}
}
else
{
Console.WriteLine(accessControlEntry1.UserOrGroupID);
}
}
}
}
© 2024 M-Files, All Rights Reserved.