Showing posts with label List. Show all posts
Showing posts with label List. Show all posts

Monday, April 22, 2024

Find smallest date from a set of dates using X++

ListEnumerator  listEnumerator;
list listDates = new  list(Types::Date);

listDates.addEnd(Date1);
listDates.addEnd(Date2);
listDates.addEnd(Date3);
listDates.addEnd(Date4);

TransDate lowestDate = dateMax();

if (listDates.elements() > 0)
{
	listEnumerator = listDates.getEnumerator();
	while (listEnumerator.moveNext())
	{
		if(listEnumerator.current() <= lowestDate && listEnumerator.current() != dateNull())
		{
			lowestDate = listEnumerator.current();
		}
	}
}

if(lowestDate != dateNull() && lowestDate != dateMax())
{
	info(lowestDate);
}

Thursday, April 22, 2021

How to get the number of elements in the list in AX

{ 
    List il = new List(Types::Integer); 
 
    il.addStart(1); 
    il.addStart(2); 
    il.addStart(3); 
    if (il.elements() != 3) 
    { 
        print "Something is wrong..."; 
    } 
}

Table browser URL in D365FO

Critical Thinking icon icon by Icons8