ReadyTaskForInitiation()
This code sample describes how to prepare a custom display step for initiation in Livelink. It stores callback scripts and any other additional data that is required by the custom display step type throughout the execution of a workflow.
Function Boolean ReadyTaskForInitiation( \
Object prgCtx, \
Record r, \
RecArray workPkg )
Assoc expandInfo
List cbInfo
List prevCBs
RecArray user
Boolean initiatorStep = False
Boolean success = True
Object const = $WFMain.WFConst
Object uSession = prgCtx.USession()
Record userData = $WFMain.WFMapPkg.CreateTaskUserDataRec()
userData.TYPE = r.TYPE
userData.SUBTYPE = r.SUBTYPE
userData.PERMFLAGS = r.USERFLAGS
//Add a standard Done callback script. This callback script is
//called when the step is completed and the workflow is routed to
//the next workflow participant. The Done callback script
//instructs all of the data types in the workflow to make a copy
//of the information that was entered for the step. The data type
//stores the information in a separate table so that each version
//is available at the end of a workflow.
if ( IsDefined( r.DONECB ) )
cbInfo = { @r.DONECB, { const.kCBSetTaskDoneData, Undefined } }
else
cbInfo = { { const.kCBSetTaskDoneData, Undefined } }
end
//If the creator of the workflow map has selected a callback
//script from the Script to run field on the Custom Display Step
//Definition page for this step, add the callback script to the
//appropriate workflow event (Step Becomes Ready or Step Is Done).
if ( IsDefined( r.EXATTS.CustTaskScript ) )
if ( r.EXATTS.RunScript == 'DoneCB' )
cbInfo = { @r.DONECB, { 500, r.EXATTS.CustTaskScript } }
else
prevCBs = r.READYCB
prevCBs = ( IsDefined( prevCBs ) ) ? prevCBs : {}
prevCBs = { @prevCBs, { 500, r.EXATTS.CustTaskScript } }
r.READYCB = prevCBs
end
end
r.DONECB = cbInfo
r.USERDATA = userData
//If the performer of the step is a group, add a callback script
//that identifies the group name. Then, if the group step is
//part of a loopback, the step is reassigned to the whole group
//when the route loops back (and not to the individual group
//member who initially accepted the step).
if ( IsDefined( r.PERFORMERID ) && ( r.PERFORMERID > 0 ) )
user = UAPI.GetByID( uSession.fSession, r.PERFORMERID )
if ( !IsError( user ) )
if ( user[ 1 ].TYPE != UAPI.USER )
prevCBs = r.PERFORMERCB
prevCBs = ( IsDefined( prevCBs ) ) ? prevCBs : {}
r.PERFORMERCB = { { const.kCBSetGrpStepPerformer, \
r.PERFORMERID }, @prevCBs }
end
end
//If the performer is Undefined, add a callback script that
//assigns the step to the initiator of the workflow.
elseif ( r.PERFORMERID == 0 )
r.PERFORMERCB = { { const.kCBGetInitiator, Undefined } }
initiatorStep = True
end
//If the performer of the step is a group, and that group should
//be expanded so that the step is assigned to all members of the
//group, add a Submap callback script. This Submap callback script
//creates a Sub-workflow that expands the members of the group.
if ( !initiatorStep )
if ( IsSet( r.EXATTS.GroupFlags ) && \
( r.EXATTS.GroupFlags != const.kWFGroupStandard ) )
expandInfo.Type = r.TYPE
expandInfo.SubType = r.SUBTYPE
expandInfo.Flag = r.EXATTS.GroupFlags
r.SUBMAPIDCB = { { const.kCBExpandGroup, expandInfo } }
end
end
return( success )
end