Discussion:
Sorting an Entry - is there a (hidden) builtin method ?
(too old to reply)
Franzw
2018-11-06 08:38:58 UTC
Permalink
I have an entry that I want to sort based on one of the attributes. I had the expectation that this would an easy task (well it was - but not directly) - I went into the apidoc for Entry - but there was no such Entry.sort(string attributename) method...

When I run my AL in the debugger the Entry is actually sorted (not showing the actually order - it will list it using attribute[n]) - so such method must exist somewhere - but I can't find it - does anybody know how to do this directly ?

Regards
Franz Wolfhagen

PS. The way I solved was creating a Java TreeSet concatenating my attribute values with a separator and using TreeSet.add() - then looping over the treeset and doing a split adding the attributes and value to a new Entry... not very complex - but not a general working method...
Eddie Hartman
2018-11-06 20:33:46 UTC
Permalink
Post by Franzw
I have an entry that I want to sort based on one of the attributes. I had the expectation that this would an easy task (well it was - but not directly) - I went into the apidoc for Entry - but there was no such Entry.sort(string attributename) method...
When I run my AL in the debugger the Entry is actually sorted (not showing the actually order - it will list it using attribute[n]) - so such method must exist somewhere - but I can't find it - does anybody know how to do this directly ?
Regards
Franz Wolfhagen
PS. The way I solved was creating a Java TreeSet concatenating my attribute values with a separator and using TreeSet.add() - then looping over the treeset and doing a split adding the attributes and value to a new Entry... not very complex - but not a general working method...
Are you saying that you want to sort a set of Entries based on one or more attributes? If so, then you will need to fiddle with it like you are doing.

/Eddie
j***@gmail.com
2018-11-14 09:46:31 UTC
Permalink
There is a hidden way to "sort" an Entry by the attributeNames.
If work has some attributes, you can try this code:
task.dumpEntry(work)
work.enableDOM();
task.dumpEntry(work)

The second dump should be sorted according to attributenames (ignoring case).
the first is maybe not.
Not sure if this helps you.
Franzw
2018-11-14 11:36:20 UTC
Permalink
Post by j***@gmail.com
There is a hidden way to "sort" an Entry by the attributeNames.
task.dumpEntry(work)
work.enableDOM();
task.dumpEntry(work)
The second dump should be sorted according to attributenames (ignoring case).
the first is maybe not.
Not sure if this helps you.
It does - indirectly :-)

What it tells me is that the entry DOM can be traversed - probably with some DOM method - and Finding that should be an educating exercise :-)

Thanks
Regards
Franz Wolfhagen

Loading...