Hi,
I am trying to get all apply records for a certain document number, document type combination. I have followed the VS Tools Programmers guide for Multi-segment keys and have the following code. The issue is that the string contains all apply records. Ones with different customers and ones that do not have an apply to document number of 12345. Can someone see what I am doing wrong?
Thanks,
Darren
// Set Reference to AR Apply Table
RmAppliedOpenTable rmApplyOpenTable = Dynamics.Tables.RmAppliedOpen;
try
{
//Set Table Key
rmApplyOpenTable.Key = 2;
//Start of Range
rmApplyOpenTable.Clear();
rmApplyOpenTable.ApplyToDocumentNumber.Value = 12345;
rmApplyOpenTable.ApplyToDocumentType.Value = 1;
rmApplyOpenTable.RangeStart();
// End of the range
rmApplyOpenTable.Fill();
rmApplyOpenTable.ApplyToDocumentNumber.Value = 12345;
rmApplyOpenTable.ApplyToDocumentType.Value = 1;
rmApplyOpenTable.RangeEnd();
//Read through all of the rows in the range
err = rmApplyOpenTable.GetFirst();
string
applies =
""
;
int
i =0;
while
(err == TableError.NoError)
{
if
(i == 0)
{
applies += rmApplyOpen.ApplyFromDocumentNumber.value;
}
else
{
applies +=
", "
+ rmApplyOpen.ApplyFromDocumentNumber.value;
}
//Get the next line item
err = rmApplyOpenTable.GetNext();
}
return
applies;
rmApplyOpen.close();