Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Content Management (Extended ECM)
CSIDE and OScript
problem with getting the workflow form data in an eventcript
Senem_Marangoz_(senemmarangoz_-_(deleted))
I am working on an event script which is supposed to get the values on the workflow webform user field and insert them to database.Here I use HTML form (submission mechanism : 'Initiate Workflow') with an automatic initiation at Start Step of the workflow. On the later steps of the workflow the event script will be executed in which i've written code to read the form data and will write it to database.I try this code,Function Boolean getFormData( \ Object prgCtx, \ WAPIWORK work, \ Integer workID, \ Integer subWorkID, \ Integer taskID, \ Integer returnSubWorkID, \ Integer returnTaskID, \ Dynamic extraData = Undefined ) String fname = "C:\log.txt" File f = File.Open( fname,File.WriteMode ) Dynamic formData Assoc fData Integer z Record r Record rx Boolean success = False Object obj = $WFMain.WFPackageSubsystem.GetItemByName( \ 'WFAttributes' ) RecArray array = $WFMain.WAPIPkg.LoadWorkData( prgCtx, work ) if ( IsDefined( obj ) ) for r in array if r.Type == 1 and r.SubType == 4 formData = r.USERDATA.Forms end end for z = 1 to length(formData) fData = formData[z].Data rx = fData.ToRecord(fData) File.Write( f, rx.Value) File.Write( f, rx.Name) end success=True end File.Close( f ) return( success )endIn the script I take the forms from the workflow data with this one, formData = r.USERDATA.Formsafter accessing the forms of the wf i take the formdata into an assoc value with this statementfor z = 1 to length(formData) fData = formData[z].Data rx = fData.ToRecord(fData) File.Write( f, rx.Value) File.Write( f, rx.Name) endHere for the simplicity i tried to write values and names of the form attributes into file. however the statement above wont write anything into file..Can anyone see what is wrong with the code or did anyone know how to get the data(attributes) of the workflow webform in a formal way? Sorry I am not familiar with oscript an wfbuilder and i am a little confused:(best regardsThanks for your answers in advance.
Find more posts tagged with
Comments
John W. Simon, Jr.
1 thing I see is you have "Object obj = $WFMain.WFPackageSubsystem.GetItemByName('WFAttributes' )" and it should be "Object obj = $WFMain.WFPackageSubsystem.GetItemByName( \'Form' )".Then the form data will be in obj.Forms. Below is a piece of code I have used to update a form field during an event script...dynamic formObject = $WFMain.WFPackageSubSystem.GetItemByName('Form')dynamic formData = formObject.LoadWorkData( prgctx, work, workid )formData.Forms[ 1 ].Data.DataAssoc.Values[ 1 ].(2).Values[ 1 ] = 'New Value'dynamic formUpdate = formObject.SaveWorkData( prgctx, work, undefined, formData )Good Luck,JWS