web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

ListIterator is null, but why?

(0) ShareShare
ReportReport
Posted on by

Hello,

I tried to execute code from the Implementing the Account and Financial Dimensions Framework (White paper), page 34. But for some mysterious reason it's not working.

DimensionValueService service = new DimensionValueService();
DimensionContract dimensionContract = new DimensionContract();
DimensionValueContract dimensionValueContract;
DimensionValue dimensionValue;
List dimensionValueContractList;
ListIterator contractorIterator;

;


dimensionContract.parmDimensionName(#DimName);
dimensionValueContractList = service.getDimensionValues(dimensionContract);
contractorIterator = new ListIterator(dimensionValueContractList);

while(contractorIterator.more())
{

dimensionValueContract = contractorIterator.value();
dimensionValue = dimensionValueContract.parmValue();
contractorIterator.next();
{info(strFmt("%1", dimensionValue));}

}


 contractorIterator is always null! And the dimensionValueContractList is initialized and has values in it.
I tried to create simple list and iterator in the same way to test it and eveything works fine.

I'm really confused, I'm missing somehting very simple.

Please help,
Thanks in advance.



*This post is locked for comments

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    237,878 Most Valuable Professional on at

    Maybe the list is on a different tier (client/server) than the enumerator. If it's the case and you use the recommended way, enumerator instead of iterator, it will work, but it would still be more efficient to do it on the same tier.

  • Community Member Profile Picture
    on at

    You were right.

    I tested Enumerator in the job and it works perfectly fine.

     contractorEnumerator = dimensionValueContractList.getEnumerator();
        
        while(contractorEnumerator.moveNext())
        {
            dimensionValueContract = contractorEnumerator.current();
            dimensionValue = dimensionValueContract.parmValue();
            {info(strFmt("%1", dimensionValue));}
        }



    But in my class I still use Iterator, but from now executing of class is on server side.
    Thank you.

  • _MGP Profile Picture
    506 on at

    I setup testing of an RDP report like this post where I create a Job, create the data contract and RDP objects before calling processReport() on the RDP object.

    However, one of the data contract parm methods was for a multi-select parameter that handled a List object.

    In the processReport() method I can see the List object having a value but then I create a ListIterator passing it the List and thereafter the ListIterator is null.

    Is the calling Job running on a different tier to the RDP object and causing this problem?

  • Martin Dráb Profile Picture
    237,878 Most Valuable Professional on at

    You wouldn't ever get into this problem in the real execution, when the RDP class would be called by a report.

    The problem is your test code, when you're creating the data contract object in a job, i.e. on client.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
Ali Zaidi Profile Picture

Ali Zaidi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans