[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.axapta.programming

COM Connector - IAxaptaRecord - iterate through fields?

5by5

12/5/2005 5:19:00 PM

I want to loop through all the fields in the IAxaptaRecord, e.g., something
like:

for i = 1 to IAxaptaRecord.method_to_return_number_of_fields()
fieldName = IAxaptaRecord.method_to_return_Nth_fieldName(i)
fieldValue = IAxaptaRecord.field(fieldName)
next

Being new to Axapta, are there methods that give me the number of fields or
the field name(s) in the above pseudocode?

Currently I am using explicit field names in the skeleton code from the VB
..NET to Axapta examples, as below.

Dim AxaptaQuery As AxaptaCOMConnector.IAxaptaObject

Dim AxaptaQueryRun As AxaptaCOMConnector.IAxaptaObject

Dim AxaptaDataSource As AxaptaCOMConnector.IAxaptaObject

Dim AxaptaRange As AxaptaCOMConnector.IAxaptaObject

Dim CustTableBuffer As AxaptaCOMConnector.IAxaptaRecord


' Find these with dict classes

CustTable = 77

CustTable_Name = 2



AxaptaQuery = Axapta.CreateObject("Query")

AxaptaDataSource = AxaptaQuery.Call("AddDataSource", CustTable)

AxaptaRange = AxaptaDataSource.Call("AddRange", CustTable_Name)



' Fill in the range from the range control

AxaptaRange.Call("Value", sRange)



AxaptaQueryRun = Axapta.CreateObject("QueryRun", AxaptaQuery)

i = 0

While (AxaptaQueryRun.Call("Next"))

CustTableBuffer = AxaptaQueryRun.Call("GetNo", 1)

currentCustomerRecord.AccountNum =
CustTableBuffer.field("AccountNum")

currentCustomerRecord.Name = CustTableBuffer.field("Name")

currentCustomerRecord.Address = CustTableBuffer.field("Address")

currentCustomerRecord.Phone = CustTableBuffer.field("Phone")

currentCustomerRecord.Telefax = CustTableBuffer.field("Telefax")

i = i + 1

End While
3 Answers

Luegisdorf

12/6/2005 7:33:00 AM

0

Hi 5by5

You can use the DictTable classes to iterate all fields of your specified
table. It have to look like this:

dictTable = axapta.CreateObject("DictTable", 77)
For i = 1 To i <= dictTable.Call("fieldCnt") Step 1

MessageBox.Show(CustTableBuffer.field(dictTable.Call("fieldCnt2Id")))
' think property field from recordBuffer should work with
fieldId ...
Next

Hope this works, if not - please respond.

Best regards
Patrick


"5by5" wrote:

> I want to loop through all the fields in the IAxaptaRecord, e.g., something
> like:
>
> for i = 1 to IAxaptaRecord.method_to_return_number_of_fields()
> fieldName = IAxaptaRecord.method_to_return_Nth_fieldName(i)
> fieldValue = IAxaptaRecord.field(fieldName)
> next
>
> Being new to Axapta, are there methods that give me the number of fields or
> the field name(s) in the above pseudocode?
>
> Currently I am using explicit field names in the skeleton code from the VB
> .NET to Axapta examples, as below.
>
> Dim AxaptaQuery As AxaptaCOMConnector.IAxaptaObject
>
> Dim AxaptaQueryRun As AxaptaCOMConnector.IAxaptaObject
>
> Dim AxaptaDataSource As AxaptaCOMConnector.IAxaptaObject
>
> Dim AxaptaRange As AxaptaCOMConnector.IAxaptaObject
>
> Dim CustTableBuffer As AxaptaCOMConnector.IAxaptaRecord
>
>
> ' Find these with dict classes
>
> CustTable = 77
>
> CustTable_Name = 2
>
>
>
> AxaptaQuery = Axapta.CreateObject("Query")
>
> AxaptaDataSource = AxaptaQuery.Call("AddDataSource", CustTable)
>
> AxaptaRange = AxaptaDataSource.Call("AddRange", CustTable_Name)
>
>
>
> ' Fill in the range from the range control
>
> AxaptaRange.Call("Value", sRange)
>
>
>
> AxaptaQueryRun = Axapta.CreateObject("QueryRun", AxaptaQuery)
>
> i = 0
>
> While (AxaptaQueryRun.Call("Next"))
>
> CustTableBuffer = AxaptaQueryRun.Call("GetNo", 1)
>
> currentCustomerRecord.AccountNum =
> CustTableBuffer.field("AccountNum")
>
> currentCustomerRecord.Name = CustTableBuffer.field("Name")
>
> currentCustomerRecord.Address = CustTableBuffer.field("Address")
>
> currentCustomerRecord.Phone = CustTableBuffer.field("Phone")
>
> currentCustomerRecord.Telefax = CustTableBuffer.field("Telefax")
>
> i = i + 1
>
> End While

5by5

12/7/2005 8:19:00 PM

0

Thanks for highlighting this class. This should do.

Since I am a newbie, could I ask where is this class documented? I've
searched through MSDN and all the Axapta/Morphx help files, and there seems
to be spotty references to DictTable, but no authoritative reference. For
example, if I wanted to know what other parameters besides fieldCnt are
available on a dictTable.Call, where might I find it?

Would you know where I should be looking? I'm even having a fun time trying
to find this in the AOT.

"Luegisdorf" wrote:

> Hi 5by5
>
> You can use the DictTable classes to iterate all fields of your specified
> table. It have to look like this:
>
> dictTable = axapta.CreateObject("DictTable", 77)
> For i = 1 To i <= dictTable.Call("fieldCnt") Step 1
>
> MessageBox.Show(CustTableBuffer.field(dictTable.Call("fieldCnt2Id")))
> ' think property field from recordBuffer should work with
> fieldId ...
> Next
>
> Hope this works, if not - please respond.
>
> Best regards
> Patrick
>
>
> "5by5" wrote:
>
> > I want to loop through all the fields in the IAxaptaRecord, e.g., something
> > like:
> >
> > for i = 1 to IAxaptaRecord.method_to_return_number_of_fields()
> > fieldName = IAxaptaRecord.method_to_return_Nth_fieldName(i)
> > fieldValue = IAxaptaRecord.field(fieldName)
> > next
> >
> > Being new to Axapta, are there methods that give me the number of fields or
> > the field name(s) in the above pseudocode?
> >
> > Currently I am using explicit field names in the skeleton code from the VB
> > .NET to Axapta examples, as below.
> >
> > Dim AxaptaQuery As AxaptaCOMConnector.IAxaptaObject
> >
> > Dim AxaptaQueryRun As AxaptaCOMConnector.IAxaptaObject
> >
> > Dim AxaptaDataSource As AxaptaCOMConnector.IAxaptaObject
> >
> > Dim AxaptaRange As AxaptaCOMConnector.IAxaptaObject
> >
> > Dim CustTableBuffer As AxaptaCOMConnector.IAxaptaRecord
> >
> >
> > ' Find these with dict classes
> >
> > CustTable = 77
> >
> > CustTable_Name = 2
> >
> >
> >
> > AxaptaQuery = Axapta.CreateObject("Query")
> >
> > AxaptaDataSource = AxaptaQuery.Call("AddDataSource", CustTable)
> >
> > AxaptaRange = AxaptaDataSource.Call("AddRange", CustTable_Name)
> >
> >
> >
> > ' Fill in the range from the range control
> >
> > AxaptaRange.Call("Value", sRange)
> >
> >
> >
> > AxaptaQueryRun = Axapta.CreateObject("QueryRun", AxaptaQuery)
> >
> > i = 0
> >
> > While (AxaptaQueryRun.Call("Next"))
> >
> > CustTableBuffer = AxaptaQueryRun.Call("GetNo", 1)
> >
> > currentCustomerRecord.AccountNum =
> > CustTableBuffer.field("AccountNum")
> >
> > currentCustomerRecord.Name = CustTableBuffer.field("Name")
> >
> > currentCustomerRecord.Address = CustTableBuffer.field("Address")
> >
> > currentCustomerRecord.Phone = CustTableBuffer.field("Phone")
> >
> > currentCustomerRecord.Telefax = CustTableBuffer.field("Telefax")
> >
> > i = i + 1
> >
> > End While

Mike Frank

12/8/2005 8:46:00 AM

0

The documentation of system classes lets better to be desired (if this is English ;-)

The only additional source of information is the cross reference, through which you can have a look
at where and how the methods on this class are used.

Mike