Iām not sure about within the datamapper without using a preprocessor script but I found a script that I modified and used a while ago that you can make use of to remove duplicates. This script will be used within the template. Just add a Script to you templates scripts pane and add the following to the scripts Selector. #table tbody tr (table is your table name, so change it to whatever you called your table.)
var seen = {};
results.each(function() {
var txt = this.text();
if (seen[txt])
this.remove();
else
seen[txt] = true;
});
Keep in mind that this script only deletes duplicate rows that are identical. For the sorting bit, I find JavaScript painful in that department. Perhaps the guys and girls here can help with that.
And as far as sorting goes, the following script takes care of it:
var items=[];
results.each(function(index) {
field = record.tables["detail"][index].fields["Number"];
items.push(field);
});
items.sort();
results.each(function(index) {
this.html(items[index]);
});
Note that this only sorts the current column and is therefore only meant as an example. You will have to adjust the code if your table has multiple columns and you want them all to follow the sort order of this column.
On the other note, thank you for the offer, I am very flattered. If you need help with developing your projects, simply get in contact with your reseller or account manager at Objectif Lune. They will then organise some Professional Service.
Iām having trouble with the Goto Step in the middle of the loop that builds the sorted Detail table. My file is TEXT, with a variable number of lines (a check register, listing check no, check amount, payee, and check date). Your goto step refers to an XPATH, but Iām not sure what Iād need to change that into for a TEXT file. Also, the how-to link in your answer is broken, it returns a 404.
The principle is the same. In fact we are really no longer concerned about looping through the lines of the text file since we have already extracted the data we need for the detail table in an array.
For your text data, after the Extract step, add a Goto step, from Top Of Record, Move To 1
The Loop ALWAYS requires a Goto Step to be included. But by moving to Line 1 from the top of the record, youāre basically staying put.
The OL Learn website structure was recently changed, so here is the new link:
Thanks; I understood all of this conceptually, even the need to have SOME sort of āgotoā inside the loop, it mattered not where it was going, simply as an artifact to give the loop something to loop throughā¦ my error was that I somehow had āInvert conditionā checked on the Loop/Repeat step so was only getting one detail record. Not seeing one tiny check mark cost me a day of head-banging, no oneās fault but my own.
FEATURE REQUEST: Ability to sort a detail (or any, for that matter) table on a specified field! Perhaps a new āActionā type? Action Type āSort Tableā, then specify the table, the field, Ascending or Descending.
The code first stores all detail lines into an array, then it sorts the array on the Total field, in descending order. And finally, it creates from that array table lines that each contain 3 cells.
You are the best Phil.
I just need to delete from the source data ā$ā in the total and start working correctly.
One more question there is any way to keep the formatting table like was before?
Because when I using this scrip formatting not working properly and grand total is missing!