cancel
Showing results for 
Search instead for 
Did you mean: 

Unity API

Shaoying_Xin2
Champ in-the-making
Champ in-the-making

My eForm become un-editable, some fields on the eForm are changed to read only, or the whole eForm can be edited which all scenarios depend on login users. If it is in one WF, I can use properties to control users or user groups, but the same eForm exists in three parallel WFs. Can Unity API check which user group or role the current login user belongs to? Could you provide some code examples?

I appreciate.

6 REPLIES 6

Lois_Nowak
Confirmed Champ
Confirmed Champ

Off the Application object, you can get the current user object.  Off this user object you can get any user groups for this user.

app.CurrentUser.GetUserGroups();

 

Coulut  you provide some code example? I want to check one user group and pass to property bag. My WF will copy the peroperty to the eForm and eForm Javascript will control the editable pemmission based on the user group.

I have some code, but it has some error, could you help me?

public void OnWorkflowScriptExecute(Hyland.Unity.Application app, Hyland.Unity.WorkflowEventArgs args)

        {

         User CurrentUser = app.CurrentUse

         PropertyBag sessionPropertyBag = args.SessionPropertyBag;

        if (CurrentUser != null)

            {

UserGroupList userGroupList = CurrentUser.GetUserGroups();

 

foreach (UserGroup userGroup in userGroupList)

                {

              foreach( Name name in userGroup.Name)

                 {

           if (name="OBRCAFinanaceWR")

                         {

                            sessionPropertyBag.Set(propUserGroup, name);

}

}

                

                }

           }

        }

Lois_Nowak
Confirmed Champ
Confirmed Champ

Each user group object in the list of user groups has an Id and a Name.  

foreach (UserGroup userGroup in userGroupList)
{
          if (userGroup.Name == "OBRCAFinanaceWR")
                {
                            sessionPropertyBag.Set(propUserGroup, userGroup.Name);
                            break;
                }
}

 

Jonathan_Perreg
Confirmed Champ
Confirmed Champ

if (name="OBRCAFinanaceWR")

...is an assignment, it should be a comparison...

if (name == "OBRCAFinanaceWR")