cancel
Showing results for 
Search instead for 
Did you mean: 

IWorkFlowScript - How to check if the user is OnBase user if not create user and add in specific user group

Pallavi_Agrawal
Champ in-the-making
Champ in-the-making

Hello,

I have a string variable in script which contains username.

I need to check if this user is exists in OnBase. If not then create that user and add that in specific user group. I am not sure how to accomplish that.

Here a code not sure if it is a correct approach .

string tryuser="ABCD";

Hyland.Unity.User user=app.Core.GetUser(tryuser);  //check if user is in OnBase

if(user==null)

{

//Create a new user and add that user in Usergroup1

}

Thanks!

1 ACCEPTED ANSWER

Aki_Daiguji
Star Contributor
Star Contributor

Hi Pallavi,

Instead of using app.Core.GetUser() method, I recommend UserAdministration.GetUsers() method to get a UserList object, and from this list object, find the specific User object you are looking for. The GetUsers() method can also take in a UserGroup object as a parameter, so you only get a list of users from that specific usergroup.

And the UserAdministration class has the functionality of creating new users and adding them to usergroups as well.

View answer in original post

6 REPLIES 6

Hi Adam and Aki ,

Thank you both for your responses. As Aki surmised, I want to know if that user exists in OnBase - If they don't exist, I will create them - modify or unlocking an existing user wouldn't happen at that point.

The reason I don't want to modify users when we check to see if they have an OnBase user account is that our implementation will cover multiple countries in many time zones. Changes to the user permissions in OnBase cannot take place in the middle of their business day, but since the base OnBase User Group only gives permission to run the clients (that is, no permission to retrieve or view document types) we are safe to create their account immediately.

Thanks again for your responses!

Haydn_Phillips
Champ in-the-making
Champ in-the-making

Its quite easy and you can do a number of things when creating new users.


UserAdministration UserAdmin = app.Core.UserAdministration;


        NewUserProperties properties = UserAdmin.CreateNewUserProperties("USERNAME", "PASSWORD");

        properties.RealName = "REAL_NAME";

        properties.EmailAddress = "EMAIL_ADDRESS";

         

        UserGroup primaryUserGroup = UserAdmin.GetUserGroups().Find(1);

        properties.PrimaryUserGroup = primaryUserGroup;


        List<UserGroup> userGroupList = new List<UserGroup>();

        userGroupList.Add(UserAdmin.GetUserGroups().Find(2));

        userGroupList.Add(UserAdmin.GetUserGroups().Find(3));


        properties.AssignNamedClientLicense = false;

        properties.AssignNamedWorkflowLicense = false;

        properties.AssignNamedWorkviewLicense = false;


        properties.TemplateUser = UserAdmin.GetUsers().Find(2);


        properties.AutoDisplayNum = 2;


        properties.ThrowExceptionOnNamedLicenseNotAvailable = true;


        User user = UserAdmin.CreateUser(properties);