Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to get the workflow form attribute data from an eventscript

Status
Not open for further replies.

yanayurt

Programmer
Sep 27, 2007
5
0
0
TR
Hi all,

I've just started to explore Builder to write an event script , but i'm too confused .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. However I am not sure about whether getting the value of some attribute of the web form in event script is possible or not. Does anyone who had done something like this before and help me about getting the value of an attribute from a web form?

best regards

Thanks for your answers in advance.

yasemin
 
there is an example included with the builder at :

<path to LL Install>/builder/documentation/wfbuilder/changeattribute.html

Greg Griffiths
Livelink Certified Developer & ECM Global Star Champion 2005 & 2006
 
you can also peruse this link which is basically some good code and instructions.
You need a nderstanding of the workflow data structure
which has by default two packages,general and attchments,when attributes enter the fray thy become 3 and when forms enter 4.

IN your case if thw webform field submits to an already running workflow then the value can be easily obtained by parsing the form package.If the webfgorm is initiating the workflow I do not know how easy it would be to write an event script.

Anyawys atake a lok at this and see if they are of help.




Look at Introduction to Eventscripts in LL workflow


Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
 
Hi again,

I tried that script with simple modifications.

As I mention I'm using 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.


RecArray attribs
Record r

Boolean found = False
Boolean success = True

//here i also tried Object obj =
//$WFMain.WFPackageSubsystem.GetItemByName('Form')
Object obj = $WFMain.WFPackageSubsystem.GetItemByName( \
'WFAttributes' )

RecArray array = $WFMain.WAPIPkg.LoadWorkData( prgCtx, work )

if ( IsDefined( obj ) )
for r in array
if ( { r.TYPE, r.SUBTYPE } == { obj.fType, obj.fSubType } )
found = True
break
end
end

if ( found )
attribs = r.USERDATA
found = False

for r in attribs
if ( r.Name == '_1_1_2_1' )
//here i tried to write r.value to a file
File.Write( f, r.Value )

found = True
break
end
end

end
end


The problem is I do not get any values into the variable array which is needed for getting the form data.
Here statement
if ( { r.TYPE, r.SUBTYPE } == { obj.fType, obj.fSubType } )
returns false ,thus found never being true and the later part wont execute as supposed.

Does anyone can see what is wrong with the code above?..

Thanks for your answers in advance.

yasemin

 
After you laod the workdata like this,I don't recall the correct syntax for form anymore but I think this is the better parsing routine

Code:
RecArray array = $WFMain.WAPIPkg.LoadWorkData( prgCtx, work )


// Go through the packages and find the form info (subtype = 4).
	for package in wfWorkPackages
		if package.Type == 1 and package.SubType == 4
			formData = package.USERDATA.Forms
			break
		end
	end

if you start looking at the dynamic formData I think you should find your form related stuff,also form attributes will alawys be of the 1_1_4_

Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
 
Hi again,

I updated my code according to your advices but I still have problem to reach the form data.

As you said I take the forms from the workflow data with this one,
formData = r.USERDATA.Forms

after accessing the forms of the wf i take the formdata into an assoc value with this statement

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

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 you see what is wrong with the code.. Sorry but i am not familiar with oscript an wfbuilder:(

Thanks for your answers in advance.


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 )
end
 
can you write to me at my email address.you could get that from nairkn dot com or greggriffiths.org I will send an event script so you can compare it with what I am doing.Do you see workid,subworkid etc filled,I just want to rule out the possibility of this

If you initiate a workflow form a form,then it is quite possible that when the event script is being executed it is kind of in a chicken/egg situation too early in the sequence,so for debugging make sure the workflow is initiated,put a user step right after that and make the event script run off in that position.

Also the form template userid should easily be trapped in your case,what is that ultimately you are trying to acheive,are you trying to use the form value to map out the next performer,in that case that is standard livelink you don't need an event script anyways.

Just trying to help event scripts are one of my favorites:) but make usre the situation warrants its use


Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top