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

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.

Good morning Aki,

We are new to scripting, so still working through the recommendations. With your recommendation we have a concern that we will have thousands of users in the user group. It just seems wasteful to pull every user just to iterate through that list to find out if one user currently has an OnBase user name.

Is there a more direct way you can recommend to determining if a User exists in OnBase, when the only user group we can be sure everyone will be in is large (ie, specifying a user group would not help cut down the size of the list).

thank you!!

Hi Dave --

I understand your concern regarding pulling a list of thousands of users but in my experience, that process will take only a few seconds (if that). I'm not currently aware of any other way to do it, but I'll look into it!

Best,
C. Adam Kuhn, API Analyst
OCAPI | OCWE | OCWA | OCASA | OCI
Hyland Software – creator of OnBase

Hi Dave,

Actually, if you are not going to do any type of administration with the User object that you get back from the Core.GetUser() method (like changing its usergroup association, changing its password, etc.), then there's no issues with using this method. It looks like all you want to do is to confirm if a user exists (to see if the User object is null or not), so if that's the case, please go ahead and use the Core.GetUser() method.