Does anyone know if it is possible to add a security tag to a user account automatically through workflow? If so, we would also like to be able to remove them from user accounts automatically...
Question
Question
ADDING AND REMOVING SECURITY TAGS TO AND FROM USER ACCOUNTS WITH WORKFLOW
Replies
You would have to use an SDK Script activity to assign the tag to a user.
AccountReference ac = new AccountReference("USERNAME",RASession); TrusteeInfo ti = Trustee.GetInfo(ac,RASession); ti.AssignTag(Tag.GetInfo("SECURETAGNAME", RASession)); Trustee.SetInfo(ac, ti, RASession); ti.Save();
Thanks very much for this info. Much appreciated
Thank you very much the posted piece of code.
We never had to add an SDK script to our workflows before so we must be missing something.
We copied and pasted the code into our workflow script but we are getting a number of errors in relation to TrusteeInfo, RASession, AccountReference. The scripting engine is obviously missing some definitions and we are not sure if this is because we are not licensed for the SDK or because we simply did not include the right libraries. Could you please clarify this for us and maybe point in the right direction?
Any help will be much appreciated.
thanks
Thank you very much the posted piece of code.
We never had to add an SDK script to our workflows before so we must be missing something.
We copied and pasted the code into our workflow script but we are getting a number of errors in relation to TrusteeInfo, RASession, AccountReference. The scripting engine is obviously missing some definitions and we are not sure if this is because we are not licensed for the SDK or because we simply did not include the right libraries. Could you please clarify this for us and maybe point in the right direction?
Any help will be much appreciated.
thanks
What version of Workflow is this? Did you add a Script activity or an SDK script one?
SDK licensing is not required to use the SDK script activity in Workflow.
Once again, thanks so much for the speedy replies. please see attached and advise. thx!
Oh, that's old. Workflow 9.0 uses LFSO for scripting instead of RepositoryAccess.
LFUser lfuser = (LFUser)this.Database.GetTrusteeByName("USERNAME"); LFTag SecureTag = (LFTag)this.Database.GetTagByName("SecureTagNAME"); lfuser.AddTag(SecureTag); lfuser.Update();
Thanks SO much. this second piece of code works. One more question: If we upgrade, will this still work?
Thanks again for all of your help
Yes, it will. It's only referencing LFSO90, which Workflow will keep installing to keep these types of scripts going because it was available as built-in reference in older versions. If you add custom references to your scripts, then you're responsible for making sure they're still available through upgrades.
Hi Miruna,
Does your original script work with tokens for the user name? I've used the Token Browser to enter the token name, but get a "Trustee not found" error. I'm using:
AccountReference ac = new AccountReference("ForEachRow_UserName",RASession);
The accounts are LF Users in Avante.
Thanks,
Mike
I'm very much a "copy and paste" developer and more often than not, don't understand how the code works, but I have got the script to work with a token via the following approach. Please feel free to correct me on it!
string acctName = GetTokenValue("ForEachRow_UserName").ToString(); AccountReference ac = new AccountReference(acctName,RASession); TrusteeInfo ti = Trustee.GetInfo(ac,RASession); ti.AssignTag(Tag.GetInfo("ThisistheTagName", RASession)); Trustee.SetInfo(ac, ti, RASession); ti.Save();
Hi Miruna,
1 LFUser lfuser = (LFUser)this.Database.GetTrusteeByName("USERNAME");
2 LFTag SecureTag = (LFTag)this.Database.GetTagByName("SecureTagNAME");
3 lfuser.AddTag(SecureTag);
4 lfuser.Update();
This piece of code works well but it seems only for Repository Users.
Our customer also has 50 Laserfiche Directory Accounts and we need to be able to assign tags to these users too. The code above returns "Trustee could not be found" error but works for regular repository user accounts. Is there anyway to adopt this code for Laserfiche Directory Accounts too?
Thank you.
This is LFSO code, not RepositoryAccess. Are we still talking about Workflow here?
Yes, we are still talking about running this in Workflow. We tried running the following piece of code you suggested earlier:
1 AccountReference ac = new AccountReference("USERNAME",RASession);
2 TrusteeInfo ti = Trustee.GetInfo(ac,RASession);
3 ti.AssignTag(Tag.GetInfo("SECURETAGNAME", RASession));
4 Trustee.SetInfo(ac, ti, RASession);
5 ti.Save();
and it works both for Repository Users and Laserfiche Directory Accounts.
Thank you for your assistance.
Workflow can manipulate tags on entries, but not the trustees of a security tag.