Hi, all.
I develop workflow, in which on initiation step user can fill, or can skip filling workflow attributes. He can specify Operator, who will finish filling attributes, or fiil them by himself and there will be no need in Operator step. I need to develop EventScript, which compares two user-attributes (Initiator of process and Operator). If it is the same person, I need to skip Operator step.
I deweloped this script, and it works fine when I attached it to some step within workflow, but fails when I attach it to the "Workflow is Initiated" event, or to Process step next by Initiation step (even at the "Step is done" event). I found, that problem is with string in my script:
RecArray workArray = $WFMain.WAPIPkg.LoadWorkData( prgCtx, work )
It simply doesn't returns data. I suggest it's tied with some workflow initiation process specific.
Does anibody knows any workaround this issue?
My script:
Function Dynamic InitiatorIsOperator( \
ObjectprgCtx, \
WAPIWORKwork, \
IntegerworkID, \
IntegersubWorkID, \
IntegertaskID, \
IntegerreturnSubWorkID, \
IntegerreturnTaskID, \
DynamicextraData = Undefined )
Booleanfound = false
Objectobj = $WFMain.WFPackageSubsystem.GetItemByName( 'WFAttributes' )
Dynamicattribs
Recordr
Integeri, z, id
DynamicattribValue = undefined, upd, InitiatorID=undefined, OperatorID=undefined
RecArray workArray=undefined
AssocretVal
retVal.ok = false
retVal.errMsg = str.format('Unable to find espected attributes')
// ************************************************************ //
// get the work array.
// ************************************************************ //
if ( isDefined(work) && !isDefined(workArray) )
workArray = $WFMain.WAPIPkg.LoadWorkData( prgCtx, work )
end
if isDefined(workArray) && !isError(workArray)
// step through the work package and find attributes.
if ( IsDefined( obj ) )
for r in workArray
if ( { r.TYPE, r.SUBTYPE } == { obj.fType, obj.fSubType } )
found = True
break
end
end
end
// ************************************************************ //
// step through wf attributes to find requested attribute.
// ************************************************************ //
if (found)
attribs = r.UserData
for i=1 to length(attribs.Content.RootSet.Children)
if (isDefined(Str.LocateI(attribs.Content.RootSet.Children[i].Name, 'Initiator')) || \
isDefined(Str.LocateI(attribs.Content.RootSet.Children[i].DisplayName, 'Initiator')))
id = attribs.Content.RootSet.Children[i].ID
attribValue = attribs.Content.RootSet.ValueTemplate.Values[ 1 ].(id).Values
InitiatorID = attribValue[1]
end
if (isDefined(Str.LocateI(attribs.Content.RootSet.Children[i].Name, 'Operator')) || \
isDefined(Str.LocateI(attribs.Content.RootSet.Children[i].DisplayName, 'Operator')))
id = attribs.Content.RootSet.Children[i].ID
attribValue = attribs.Content.RootSet.ValueTemplate.Values[ 1 ].(id).Values
OperatorID = attribValue[1]
end
end
if(isDefined(InitiatorID) && isDefined(OperatorID))
if(InitiatorID == OperatorID)
for i=1 to length(attribs.Content.RootSet.Children)
if (isDefined(Str.LocateI(attribs.Content.RootSet.Children[i].Name, 'InitiatorIsOperator')) || \
isDefined(Str.LocateI(attribs.Content.RootSet.Children[i].DisplayName, 'InitiatorIsOperator')))
id = attribs.Content.RootSet.Children[i].ID
attribs.Content.RootSet.ValueTemplate.Values[ 1 ].(id).Values = True
break
end
end
end
end
// ************************************************************ //
// save the attribute object data
// ************************************************************ //
r.UserData = attribs
retVal = obj.SaveWorkData( prgCtx, work, undefined, r.UserData )
end
end
return (retVal)
end