PutMapData()
This code sample describes how to save the data that the creator of a workflow map enters on the Custom Display Step Definition page.
function assoc PutMapData( \
Object prgCtx, \
Record mapRec, \
Record taskInfo, \
Record r )
Assoc paneData
Assoc retVal
Integer defaultDispo
Integer flags
Integer i
Integer permAndDispositionFlags
List dispositions
List emptyDispos
Object obj
Real time
Record p
Integer count = 0
retVal.OK = TRUE
if ( ( r.PaneIndex == 1 ) || ( r.PaneIndex == 0 ) )
//Save the step name.
if ( RecArray.IsColumn( r, 'Title' ) )
taskInfo.Title = $LLIAPI.FormatPkg.ValToString( r.title )
end
//Save the start date.
if ( RecArray.IsColumn( r, 'StartDate' ) )
taskInfo.StartDate = ._CrackDate( r.StartDate )
end
//Save the instructions.
if ( RecArray.IsColumn( r, 'Instructions' ) )
taskInfo.Instructions = \
$LLIAPI.FormatPkg.ValToString( r.Instructions )
end
//Save the callback script that the creator of the workflow map
//selects from the Script to run field.
if ( IsFeature( r, 'CustTaskScript' ) && ( \
r.CustTaskScript != [WebWFP_HTMLLabel._None_] ) )
taskInfo.ExAtts.CustTaskScript = r.CustTaskScript
//Save the information about when to execute the callback
//script (that is, the workflow event that triggers the
//callback script).
taskInfo.ExAtts.RunScript = r.RunScript
else
taskInfo.ExAtts.CustTaskScript = Undefined
end
//Save the template that the creator of the workflow map
//selects from the Template to use field.
if ( IsFeature( r, 'CustTaskTemplate' ) && ( \
r.CustTaskTemplate != [WebWFP_HTMLLabel._None_] ) )
taskInfo.CustomData.CustTaskTemplate = r.CustTaskTemplate
else
taskInfo.CustomData.CustTaskTemplate = Undefined
end
//Save the duration.
if ( RecArray.IsColumn( r, 'Duration' ) )
if IsDefined( r.Duration ) && Length( r.Duration )
Boolean inDays = ( r.DurationUnits == "Days" )
time = $LLIAPI.FormatPkg.StringToVal( r.Duration, \
RealType )
if ( Type( time ) != RealType )
retVal.OK = FALSE
if inDays
retVal.ErrMsg = \
[WebWork_ErrMsg.DurationMustBeANumberOfDays]
else
retVal.ErrMsg = \
[WebWork_ErrMsg.DurationMustBeANumberOfHours]
end
else
taskInfo.DueDuration = \
$LLIAPI.FormatPkg.ConvertToSeconds( inDays, time )
end
else
taskInfo.DueDuration = Undefined
end
end
//Save the group options.
if RecArray.IsColumn( r, "GroupFlags" )
taskInfo.EXATTS.GroupFlags = Str.StringToInteger( \
r.GROUPFLAGS )
end
elseif ( r.PaneIndex == 2 )
//Save the disposition types.
for i = 1 to 5
if ( RecArray.IsColumn( r, Str.Format( "disposition_%1", \
i ) ) ) && \
Length( r.( Str.Format( "disposition_%1", i ) ) )
dispositions = { @dispositions, r.( Str.Format( \
"disposition_%1", i ) ) }
else
emptyDispos = { @emptyDispos, i }
end
end
if RecArray.IsColumn( r, "disposition_selected" )
defaultDispo = $LLIAPI.FormatPkg.StringToVal( \
r.disposition_selected, integerType )
//Retrieve the disposition settings from the Permissions tab
//for this step. Ignore those fields in which no values have
//been specified.
for i in emptyDispos
if ( i > defaultDispo )
count += 1
end
end
defaultDispo -= count
If ( Length( dispositions ) > defaultDispo )
retVal.OK = FALSE
retVal.ErrMsg = \
[WebWork_ErrMsg.DefaultDispositionMustHaveAName]
end
else
defaultDispo = 1
end
if RecArray.IsColumn( r, "RequireDisposition")
flags |= $WFPDisposition
else
dispositions = { 'Approve', 'Reject' }
end
//Save the permissions settings.
if RecArray.IsColumn( r, "SeeAllComments" )
flags |= $WFPComments
end
if RecArray.IsColumn( r, "SendForReview" )
flags |= $WFPReview
end
if RecArray.IsColumn( r,"Delegate" )
flags |= $WFPDelegate
end
taskInfo.USERFLAGS = { flags, { { @dispositions }, \
defaultDispo } }
else
//Determine whether the data types that are attached to the
//workflow need to display anything before setting up the data
//for a particular step. For example, the custom display step
//type needs to display a tab that allows the creator of a
//workflow map to specify whether certain workflow attributes
//are editable, required, or read-only.
i = 3
for p in mapRec.WORK_PACKAGES
obj = $WebWFP.WFPackageSubsystem.GetItem( { p.TYPE, \
p.SUBTYPE } )
if ( IsDefined( obj ) && IsDefined( p.USERDATA ) )
paneData = obj.GetMapData( prgCtx, taskInfo, p.USERDATA )
if ( IsDefined( paneData ) )
if ( i == r.PaneIndex )
retVal = obj.PutMapData( prgCtx, taskInfo, \
p.USERDATA, r )
break
else
i += 1
end
end
end
end
//Save any callback data.
$WEBWFP.WFContentManager.StoreCallbackData( taskInfo, \
r )
end
return retVal
end