Originally Posted by chrisK
|
I am trying to get access to the Item tax amount through scripting. It shows up under dtr:Items -> dtr:Item -> dtp:ItemTaxes -> dtp:ItemTax -> dtp:amount.
Although ItemTaxes is a member of Item, ItemTax generates an error when i try to access it as a member of ItemTaxes.
How can i reference this value?
Thanks
ck
|
Well, I'm not sure of the greater context, but here's a go.
A couple of things here that are probably tripping you up. The first is that that there may be one or more ItemTax nodes in the XML. This allows us to support Canadian taxes where there are multiple tax codes for each item.
The easiest thing to do is create a calculated field and set the value in script.
Here's a link for the basic steps (there's a word doc in the zip file):
http://downloads.d-tools.com/si5/rep...o_A_Report.zip
For your specific question, you would do this in the FetchData event:
|
Code:
|
' Add the custom field
Sub ActiveReport_DataInitialize
' Add the calculated field to the data
rpt.Fields.Add("ItmTax")
End Sub
Function ActiveReport_FetchData(ByVal EOF As Boolean) As Boolean
' return the current item that is being iterated over. (this works for all proposals and most reports
' the report must be iterating over the Item or ProposalItem nodes in the data
Dim itm As DTools.SystemIntegrator.Reporting.Item = ReportUtilities.ReturnItem(rpt)
' Create a variable for an ItemTax object
Dim it as DTools.SystemIntegrator.Common.ItemTax = Nothing
' If the item is not null, set value of the calculated field
If itm IsNot Nothing Then
' Loop the ItemTaxes collection and add up the total amounts of the item tax
For Each it in itm.ItemTaxes
' set the value of the calculated field.
rpt.Fields("ItmTax").Value += it.Amount
Next
End If
' Must return EOF
Return EOF
End Function |
If you follow the rest of the info in the word doc, you should be able to bind a textbox to the
ItmTax data field.
-R