Here is a snippet from an aux script that I run to generate a report. The report outputs in HTML. Hope you can get something out of it... I'm not a programmer, there is probably a better way, this just seems to work for me.
Sub itemHTML( item, fldname ) 'This sub routine prints out the QAR information.
Dim fldList, fld_issue_type,fldObj2,fld_issueid,fld_state,issue_id_var,issue_type_var,var_parentID,ok,fld_description
Dim whereclause,parentRec,sIssueID,action_owner_var,state_var,fld_severity,severity_var,process_prod_var
Dim fld_prod_app,description_var, fld_prod_name,prod_name_var,fld_source,issue_source_var,fld_prod_type
Dim fld_location,location_var
Set fldList = item.Fields()
Set fld_issue_type = fldlist.FindField("ISSUETYPE")
Set fld_issueid = fldList.FindField("ISSUEID") 'Issue ID
Set fld_source = fldList.FindField("SOURCE") '#####NEW TEST
Set fld_state = fldlist.Findfield("STATE")
set fld_description = fldlist.Findfield("DESCRIPTION")
Set fld_severity = fldlist.Findfield("RISK_PRIORITY")
set fld_prod_app = fldlist.Findfield("PRODUCTAPPLICATION")
set fld_prod_name = fldlist.Findfield("PRODUCT_NAME")
set fld_location = fldlist.Findfield("LOCATION")
Call fld_issue_type.GetDisplayValue(issue_type_var)
Call fld_issueid.GetDisplayValue(issue_id_var) 'Get the display value of the issueID
Call fld_source.GetDisplayValue(issue_source_var)
Call fld_state.GetDisplayValue(state_var) 'Get the display value of the current state
Call fld_description.GetDisplayValue(description_var)
nParentID = item.GetId()
set parentRec = Ext.CreateVarRecord(main_table_name)
ok = parentRec.Read(nParentID)
call parentRec.GetFieldValue("POC2",action_owner_var) 'action owner is a single-user field.
if getspocname(action_owner_var) Then 'Function to get the action owner name
get_poc
End If'
Call fld_severity.GetDisplayValue(severity_var) 'Get the severity value from Risk/Priority field.
Call fld_prod_app.GetDisplayValue(process_prod_var) 'Get the process/product value.
Call fld_prod_name.GetDisplayValue(prod_name_var)
Call fld_location.GetDisplayValue(location_var)
if issue_id_var > 0 and issue_type_var = "QCR" Then
Call Ext.WriteStream("<tr><td><b><left>" & issue_type_var & "_" & issue_id_var & "</b></td><td> <b>" & issue_source_var & "</b></td><td> <b>" & state_var & "</b></td><td><b>" & description_var & "</b></td><td><b>"& severity_var & "</b></td><td> <b> " & returned_owner_name & "</b></td><td><b> " & process_prod_var & " </left></b></td><td><b> " & prod_name_var & " </left></b></td><td><b> " & location_var & " </left></b></td></tr>")
if getsubitemlist() Then 'Function to get the data out of the TS_SUBTASKS table
sub_result 'sub to process the results from the sub table
end if
End if
End Sub