Customisation Title | Resolve group step workflow task issue if only single user in group |
---|---|
Purpose of Customisation | In some cases you will have a workflow task assigned to a group containing only a single user. However, at present Livelink still sees that step as a Group Step, requiring the user to click ok on a popup and then accept the assignement prior to wokring on it. This cusomisation resolves that issue |
Author | Greg Griffiths |
Date of Customisation | 27 April 2005 |
Covers Livelink | Livelink 9.2/9.5 |
Livelink Modules | WebWork |
Affected Templates | \module\webwork\tgenericframe.html |
Customisation Format | HTML |
Download Here |
Download as a ZIP file for LL 9.2 Download as a ZIP file for LL 9.5 |
When you are building Workflows, you should always assign steps to a group rather than a single user to make future management easier. However, in some cases, your groups may have a single user in them at some point in time. Unfortunately, LiveLink does not handle this as well as it might and just sees that the step is assigned to a group and does not take the next step of realising that there is only a single user in that group and directly assign the task to them, this customisation resolves that.
The first thing we do is check to see if the group assigned to the task only has one user in it. This is done by connection to the Users and Groups API (UAPI) and getting information on the user/group assigned the current task, if it is a group which contains a single member - a user - then set the boolean.
workDone = ( IsDefined( workDone ) )? workDone : Assoc.CreateAssoc()
Object prgCtx1 = Undefined
Boolean singleUserGroup=False
if (Os.IsFeature( this, "fPrgCtx" ) )
prgCtx1 = .fPrgCtx
end // if
if ( IsDefined( prgCtx1 ) && IsNotError( prgCtx1 ) )
Dynamic userObject = prgCtx1.USession()
if ( IsDefined( userObject ) && IsNotError( userObject ) )
UAPISession uapiSession = userObject.fSession
if ( IsDefined( uapiSession ) && IsNotError( uapiSession ) )
RecArray userInfo = UAPI.GetByID( uapiSession, taskInfo.SUBWORKTASK_PERFORMERID )
if ( IsDefined( userInfo ) && IsNotError( userInfo ) )
String userType = Str.String(userInfo[1].Type)
if (userType=="1")
RecArray groupMembers=UAPI.ChildrenListByID(uapiSession,userInfo[1].Id)
Integer groupMembersLength=Length(groupMembers)
if ((groupMembersLength==1) && (groupMembers[1].Type==UAPI.USER))
singleUserGroup=True
end
end
end
end
end
end
;if (( taskData.GroupStep ) && (!singleUserGroup))
alert( `%LStr.CString( Str.Format( "%1 %2", [WebWork_HTMLLabel.ThisStepAssignmentHasBeenOfferedToMoreThanOnePerson], [WebWork_HTMLLabel.ItMustBeAcceptedBeforeWorkCanBeDone] ), "'" )` );
;end
Now that that is done, all that remains is to dynamically accept the task on the users behalf. Initially I was planning to do this entirely in OScript/WebLingo, but as the task acceptance updates the database tables, I decided to simply use some Javascript to programatically click the accept button on the users behalf. The Javascript simply cycles though the form elements until it finds the button with the correct label, and then calls that buttons onclick event to programatically accept the users task for them, usually this is done so quickly that the user does not notice the refresh.
;if (singleUserGroup)
<script language="javascript">
for (i=0;i<document.myForm.length;i++)
{
if ((document.myForm.elements[i].value=="Accept Assignment") && (document.myForm.elements[i].type=="button"))
{
document.myForm.elements[i].click();
}
}
</script>
;end
<!-- End File: webwork/tgenericframe.html -->
;;end