I’ve successfully created a method for emailing an HTML formatted listed of items from my Glide App, based on general the approach described here (except that instead of the resulting output being a list of comma separated values, it is a list of values surrounded by html tags).
Everything works as needed EXCEPT the bulleted list is not sorted in the order I need it to be sorted in. It is sorted in the order that the selected items appear in the Glide table they are drawn from. Unless I’m mistaken, you can’t sort a Glide Table in the data editor (if I’m wrong, let me know because that would probably solve my problem).
So, I’m trying to figure out how to sort the list before it is delivered through Make to the body of the email. I tried various ways of using sort Array to change the order of the items in the relation, but that did not work.
Unless there is another solution, I’m thinking I would use a javascript column to sort the list items (each of which are surrounded by an < li > tag) and use that column as the output for the email. I’m pretty much a complete javascript novice, so although there are lots of examples online of javascript code to sort an html list, I can’t seem to get anywhere close to implementing them in Glide to accomplish this.
So my questions:
- Is there a better solution to my problem than using javascript?
- If not, any guidance on how to implement this in Glide would be great. I’m not totally sure how to implement the javascript column. For example, this is a pretty straightforward example I found online but I don’t know how to adapt it in the Javascript column.
var listItem = document.getElementById(‘list’).getElementsByTagName(‘li’);
var listLength = listItem.length;
var list = ;
for(var i=0; i<listLength; i++)
list[i] = listItem[i].firstChild.nodeValue;
list.sort();
for(var i=0; i<listLength; i++)
listItem[i].firstChild.nodeValue = list[i];