I have an app for the church I Pastor to manage the Retreat events for the womens group that my wife leads. I need to print a list that I have created using json and joined list and then created an array and print that via docsautomator. The list is not organized. I can’t find a way to group by a field and then sort those groups by the name field.
Have you tried using a query column to sort the data, and then get your joined list from the query?
Duh…no Jeff but I will do that now! Thanks…still on the learning curve and Query slips by me to often!
Ok I now realize that i can’t do that because I get my data for the joined list from the JSON object that I built and it has 4 different bits of info…and when I sort the data in a query I don’t see that column as an option to add to my JSON build…in other words I sort the name via the Query but I can’t add that query_name column as part of my JSON…
What would you expect it to look like if you want to do “group by”? Then how do you pass that to DocsAutomator? As different arrays?
I want them grouped by T-Shirt size and then in each group the ladies names would be in a-z order.
It would be nice to be able to put a few blank lines or a horizontal solid line between the groups. Or I would need to create the arrays for the groups sorted and then create one array from them and pass them to DocsAutomator as one.
From “Thịnh Đinh via Glide Community” <notifications@glideapps.discoursemail.com>
To jerryrankin@gmail.com
Date 4/10/2024 6:31:39 PM
Subject [Glide Community] [Ask for Help] Sort array for report
@Rupert Am I right that you can not dynamically group things like that when you pass an array to DocsAutomator?
As far as I know I only get to pass the array and it creates the pdf from that …no manipulation of the data in any way.
Ok I went to OpenAi and ask it to take the current array and group it by tshirt size and the sort by name a-z and give me the result in another array. Worked and I copied that array into a new column and used it to print via DocsAutomator. That does not fix the issue long term since I did not create the array inside the app and if any of the data changed then it would not be accurate. Still looking to figure it out for future use on events. Thanks.
Can you show us of an example document you generated with this approach?
You can tell OpenAI to generate the JavaScript function to take the input as you format it, and then output a JSON string that can work with DocsAutomator.
OpenAI is what is used to create the JS to do the work and then ran that code in Chrome java environment to generate the array output. Then created a new text column and copied array into the text column and pointed DocsAutomator at that column…and bingo.
So it’s not that you want to group sizes and create different tables, but rather sorting by size first, and then sort by name?
Correct…It would be nice to add a couple of blank lines for spacing between them (which I can do by editing the array) but this works. Again would love to be able to accomplish this inside the app in Glide but… someday
J
From “Thịnh Đinh via Glide Community” <notifications@glideapps.discoursemail.com>
To jerryrankin@gmail.com
Date 4/11/2024 6:42:27 PM
Subject [Glide Community] [Ask for Help] Sort array for report
Can this javascript be executed via a button inside Glide and pass the array from my table to it and receive the resulting array to be passed to docsAutomator to print?
function groupAndSortByTshirtSizeWithSeparators(items) {
// Group by t-shirt size
const groupedBySize = items.reduce((acc, item) => {
const size = item.line_items_tshirt_size;
if (!acc[size]) {
acc[size] = [];
}
acc[size].push(item);
return acc;
}, {});
// Create a new array with sorted groups and add separators
const sortedAndSeparated = [];
Object.keys(groupedBySize).sort().forEach((size, index, array) => {
const sortedGroup = groupedBySize[size].sort((a, b) => a.line_items_name.localeCompare(b.line_items_name));
sortedAndSeparated.push(...sortedGroup);
// Add a separator if it's not the last group
if (index !== array.length - 1) {
sortedAndSeparated.push({"separator": "--------------------------------"});
}
});
return sortedAndSeparated;
}
// Example usage:
const myItems = [
{"line_items_name":"Trisha Wylie","line_items_room":"PS 307","line_items_roommate":"Mia Paek","line_items_tshirt_size":"L"},
{"line_items_name":"Donna McMurry","line_items_room":"BB 403","line_items_roommate":"Katherine Mitchell","line_items_tshirt_size":"3XL"},
{"line_items_name":"Sue Johnston","line_items_room":"BB 401","line_items_roommate":"Martha Suarez","line_items_tshirt_size":"L"},
// Add more items as needed...
];
const sortedItemsWithSeparators = groupAndSortByTshirtSizeWithSeparators(myItems);
console.log(sortedItemsWithSeparators);
Sorry for late reply @ThinhDinh @pipharvester
Currently grouping is not possible, but it’s much requested and will be available soon. It’ll be set right from the DocsAutomator interface.
That is fantastic news!
From “Rupert Hoffschmidt-McDonnell via Glide Community” <notifications@glideapps.discoursemail.com>
To jerryrankin@gmail.com
Date 4/12/2024 11:55:38 AM
Subject [Glide Community] [Ask for Help] Sort array for report
Have you tried using a JavaScript column?
You also have to take into account the input is a string, not a JSON object in the column’s view, so parse it accordingly before doing any manipulations.
No I have not. I will go read up on JavaScript column.
J
From “Thịnh Đinh via Glide Community” <notifications@glideapps.discoursemail.com>
To jerryrankin@gmail.com
Date 4/12/2024 7:09:49 PM
Subject [Glide Community] [Ask for Help] Sort array for report