Brad
Brad

Reputation: 1369

Object Not Initialized

Creating a server-side X++ class.

Everything works fine when the class is set to run on "Called From" or "Client", but if I change it to "Server" (which is what our client wants) I receive an error message that objects are not initialized.

In this case, "ListIterator is not intialized"

public static void myMethod(list _keyValuePairs)
{
    ListIterator keyValueIterator;

    keyValueIterator = new ListIterator (_keyValuePairs);
    while (keyValueIterator.more())
    {
        //do things here
        keyValueIterator.next();
    }
}

Any suggestions?

Upvotes: 1

Views: 3279

Answers (2)

CatchPokemon
CatchPokemon

Reputation: 21

Try Enumerator like this:

List list = new List(Types::Integer);
Enumerator en ;
list.addEnd(333333); // add the value at last
list.addEnd(111111);
list.addEnd(222222);
en = list.getEnumerator();
print list.elements(); //"print number of element"

while (en.moveNext())
{
print en.current();
}
pause;

Source: https://msdax.wordpress.com/2009/10/07/list-class/

Upvotes: 1

FH-Inway
FH-Inway

Reputation: 5117

In my experience this problem usually occurs if the pack/unpack pattern that is used to transfer class attributes from one tier to the other was not implemented for the class. Your comments indicate the same (initialization on client, execution on server).

Upvotes: 3

Related Questions