ChangeAttribute()
This code sample describes how to update an attribute in a workflow.
Function Boolean ChangeAttribute( \
Object prgCtx, \
WAPIWORK work, \
Integer workID, \
Integer subWorkID, \
Integer taskID, \
Integer returnSubWorkID, \
Integer returnTaskID, \
Dynamic extraData = Undefined )
//The following variable declarations are taken from the
//prototype for the general event trigger scripts. This
//information is stored in the 0Documentation() script
//that is contained in the GeneralCallbackScripts object in your
//custom module.
RecArray attribs
Record r
Boolean found = False
Boolean success = True
//The following variable declaration references the attributes
//API object. This object contains the scripts that store data in
//the database, retrieve data from the database, and delete data
//in the database. All of the different types of data that pass
//through a workflow have an attributes API object. The
//attributes API objects are all children or orphans of
//WFMain:WFRoot:WFObjectTypes:WFDataTypes.
Object obj = $WFMain.WFPackageSubsystem.GetItemByName( \
'WFAttributes' )
//The following variable declaration calls the script that loads
//the different types of data that are flowing through the
//workflow.
RecArray array = $WFMain.WAPIPkg.LoadWorkData( prgCtx, work )
//Walk through all the different types of data that are flowing
//through this workflow, (for example, comments, attachments,
//forms, attributes) and locate the workflow attributes.
if ( IsDefined( obj ) )
for r in array
if ( { r.TYPE, r.SUBTYPE } == { obj.fType, obj.fSubType } )
found = True
break
end
end
//When the attribute's RecArray is found, store it in attribs.
//Then reset the found variable so that it can be used again.
if ( found )
attribs = r.USERDATA
found = False
//Walk through the attributes and locate the one that you
//want to update. Then update its value.
for r in attribs
if ( r.Name == 'desired attribute' )
r.Value = 'Some new value'
found = True
break
end
end
//When the attribute is updated, save the new workflow data.
if ( found )
success = obj.SaveWorkData( prgCtx, work, Undefined, \
attribs )
end
end
end
return( success )
end