cancel
Showing results for 
Search instead for 
Did you mean: 

Run Unity Script as Different User

Keith_Zejdlik
Star Contributor
Star Contributor

I have a life cycle where we need the ability to send a notification to all users in a user group and the user group notified is dependent upon a keyword on the document. Since there are over 40 user groups this is not practical to handle with rules and actions. I wrote a workflow script that gets the user group and outputs a list of email addresses to a workflow property. However, this script is being run under an ad hoc task and the user running it does not necessarily have user administration access. I know that one workaround is to have the script run under a timer, but this would really complicate the logic in the life cycle. Is there any way to run a script under a different user than the one executing it?

Thanks,

Keith

2 ACCEPTED ANSWERS

Alex_French
Elite Collaborator
Elite Collaborator

There are (at least) two distinct ways to to access some User/Group information.

For your use, you should be able to get all the current user's groups with:

app.CurrentUser.GetUserGroups();

You'll get a UserGroupList with objects that give you group Names and IDs for groups the current user belongs to.  No ability to do administration on them (even if the user did have User Administration rights), but I think this meets exactly what you need.

 

 

View answer in original post

Walter_Fernande
Confirmed Champ
Confirmed Champ

You have 2 options:

- Made a WebService that use Unity API SDK and run with your desired administrative user.

- Access through SQL to useraccount , userxusergroup and usergroup tables and get your info. (This is not the Hyland's prefered way)

 

Best regards

Walter Fernández R.

View answer in original post

4 REPLIES 4

Alex_French
Elite Collaborator
Elite Collaborator

There are (at least) two distinct ways to to access some User/Group information.

For your use, you should be able to get all the current user's groups with:

app.CurrentUser.GetUserGroups();

You'll get a UserGroupList with objects that give you group Names and IDs for groups the current user belongs to.  No ability to do administration on them (even if the user did have User Administration rights), but I think this meets exactly what you need.

 

 

I re-read your original post and realized I mis-understood, my suggestion would not help.

Walter's two suggestions are reasonable.  I would *definitely* jump straight to reading the database from your Unity SCript myself.

Some other options you might think about:

1) Pass the document through a Load Balanced queue (it doesn't have to *stay* there) and send the email based on load balanced members.

2) You *can* create a *second* Unity API session as a different super-user inside your Unity script.  Seems very goofy, but it is technically possible.

3) Find another way to get your info in Workflow- an External SQL Autofill that takes your User Group KW, goes to the OnBase database and fills a new Email Recipient KW with all members.  Is this better than doing the DB query in a Unity Script?  Depends on what seems easier and cleaner to you.

Thanks to both of you! We don't have the licensing to be able to create a connection to a new application so unfortunately I can't do that. I like the idea of an autofill because that seems a bit more kosher, but I'm still weighing the options on that.

Walter_Fernande
Confirmed Champ
Confirmed Champ

You have 2 options:

- Made a WebService that use Unity API SDK and run with your desired administrative user.

- Access through SQL to useraccount , userxusergroup and usergroup tables and get your info. (This is not the Hyland's prefered way)

 

Best regards

Walter Fernández R.