- 1 x Token (Open WF Admin -> Options -> Tokens)
- 1 x Alias for each Department
- 1 x Alias for each Workflow Step (eg if the WF has 3 steps in document approval than 3 x Aliases)
Now I initially assumed that if I created a Token and added two of the
<$wfAddUser(dWfStepName, "alias")$>
<$wfAddUser(xDepartment, "alias")$>
Statements that it would create an intersection of the Aliases, but instead it just acts as a Union!
But alas you can write IdocScript within the Token! which allows us to programmatically utilize <$wfAddUser(UCMUSER, "user")$>
So I wrote the following script
//SET
ALIASES TO BE COMPARED
<$WFALIAS1NAME
= "dWfStepName"$>
<$WFALIAS2NAME
= "dDepartment"$>
//STRING TO STORE USERS FOR
COMPARISON
<$WFUSERSTRING
= ""$>
//EXECUTE SERVICE TO LOAD ALL
ALIASES & THEIR USERS
<$executeService("GET_ALIASES")$>
<$name="AliasUserMap"$>
<$var
= rsFirst(name)$>
<$loopwhile
getValue(name, "#isRowPresent")$>
<$alias = getValue(name, "dAlias")$>
<$user = getValue(name, "dUserName")$>
//IF ALIAS RS Equals the Alias
we are searching for
<$if WFALIAS1NAME LIKE alias$>
//ADD USER FROM ALIAS MATCH 1
TO USERSTRING
<$WFUSERSTRING = WFUSERSTRING & "," & user$>
<$endif$>
<$var = rsNext(name)$>
<$endloop$>
//START CHECKING THE SECOND
ALIAS
<$executeService("GET_ALIASES")$>
<$name="AliasUserMap"$>
<$var
= rsFirst(name)$>
<$loopwhile
getValue(name, "#isRowPresent")$>
<$alias = getValue(name, "dAlias")$>
<$user = getValue(name, "dUserName")$>
//IF ALIAS RS Equals the
Alias we are searching for
<$if WFALIAS2NAME LIKE alias$>
//IF THE USER IS IN THIS ALIAS
& HAS A MATCH IN USER STRING ADD TO WF
<$if strIndexOf(WFUSERSTRING,user) !=-1 $>
<$wfAddUser(user, "user")$>
<$endif$>
<$endif$>
<$var = rsNext(name)$>
<$endloop$>
The script adds the user by looping the first alias creating a string of users in that alias, then looping the second alias and searching for matching users.
jiri.machotka commented on my OTN Post recommended
"rsMergeReplaceOnly() function (see Idoc Script Functions and Variables - 11g Release 1 (11.1.1)). You could create an intersection of the two aliases (by two calls of the function), and then add all remaining users in one loop."
Which sounds like a much cleaner solution that I intend to implement.
No comments:
Post a Comment