Freemarker Help: Pass Data to List Directive for Sorting - freemarker

First time poster and a Freemarker novice. I'm hoping someone can assist on this. I am currently referencing data from a 1-to-many table using the <#data> directive. I want to sort the results in a particular field order, but I think that can only be done by the <#list> directive. Here's what I have so far:
There's a CART_ABANDONMENT table with the following fields:
CUSTOMER_ID_
PRODUCT_ID
PRODUCT_NAME
PRODUCT_PRICE
ABANDONED_DATE
<#data CART_ABANDONMENT as abandonment><br>
<#filter CUST_ID="${CONTACTS_LIST.CUSTOMER_ID_}"><br>
<#fields PRODUCT_ID PRODUCT_NAME PRODUCT_PRICE ABANDONED_DATE><br>
${abandonment.PRODUCT_NAME} ${abandonment.PRODUCT_PRICE}<br>
</#data>
What I want to do is to list all related results (by CUSTOMER_ID_) and sort them by PRODUCT_PRICE, descending.
It may be something simple, but I haven't been able to find the answer.
Any guidance would be appreciated.

Freemarker is powerful tool tool but it's just template engine.
It has the sort directive for list, but it can be applied only to built-in types: String, Number and Date.
You may convert list of you complex type to one or more lists of built-in types and use ?sort in template.
Another way is to pass already sorted(as you want) list to template before processing.

What you want sounds like something that should be solved on the database (SQL) level, especially where you say "list all related results (by CUSTOMER_ID_)". FreeMarker is only the V (for View) in MVC.

Related

Google Sheets - QUERY order by dependent drop down

I am trying to setup a QUERY with dynamic ordering. I've tried to link the ORDER BY function to the output of the dropdown menu but that doesnt seem to work. I have recreated the problem with a simple example: https://docs.google.com/spreadsheets/d/1m3Lhm5lp2DW7XF8hRbDAiOAAsOyCXrie-Nc-0bWG6hA/edit?usp=sharing
I've created a table (3x4) with three variable and would like to dynamically sort the table by each variable through QUERY both ascending and descending.
Would also be interested to learn if it's possible to dynamically setup the direction (ACS or DESC).
Any suggestions would be much appreciated.
Kind regards,
Webko
try:
=QUERY({A2:C6}, "order by Col"&MATCH(F1, A2:C2, 0)&" "&G1)
where G1 dropdown is asc,desc

Can a PowerApps gallery be sorted from a derived column?

I have a PowerApps gallery that lists data from 3 different tables and have it normally sorted by the following:
SortByColumns(Filter(Personnel, !Dismissed, txtMSSearchBox.Text in MemberName), "MemberName", If(SortDescending1, SortOrder.Descending, SortOrder.Ascending))
One of the fields is displayed from the below:
Last(SortByColumns(Filter(PersonnelEvents, MemberNumber.Id = ThisItem.ID, EventType.Value="Promotion"), "Date", SortOrder.Ascending)).Title
What I would like to do is sort the gallery by this derived data. Is this even possible?
Can you try making On visible of the screen have an UpdateContext function which saves this formula as a variable.
You can then reference this variable as the column you want to sort by.
i.e something like UpdateContext({mySortColumn: Last(SortByColumns(Filter(PersonnelEvents, MemberNumber.Id = ThisItem.ID, EventType.Value="Promotion"), "Date", SortOrder.Ascending)).Title})
I just hope I really understand what you are trying to achieve, but if this doesn't work, maybe you can explain better what you are trying to do and hopefully I'll be able to help
I have decided to use Flow to update a column in my main table to show the relevant data and thereby sort by that field. I believe this would be an easier way to accomplish what I want.

Qlikview: Matching columns of two indirectly link tables does not work

Following is the data model of the dashboard I am facing problem in:
http://blob:http://stackoverflow.com/f3e40cfe-e009-4d03-bcf5-b7b4305c18c4
Now, what i want to achieve is that in Case there is a filed named Manufacturing_Date. And in MWODefetcs there is a field named Defect_Date. What i want is that when ever a record is selected from a table containing cases from Case corresponding records are shown in another table based on the exact match of Manufacturing_Date=Defect_Date.
As simple as it sounds, i can not seem to accomplish it. I have tried the following expressions to no avail:
Count({<[Defect_Date_text]=p([Manu_text]),FaultID=,DEFECT_CODE=>}MFG_BARCODE_NUM)
sum({$<Defect_Date ={"=$(Manufacturing_Date__c)"}>}Defect_Date)
Do the 2 tables need to be directly linked. Is it the intermediary iFaults table that is preventing me to accomplish it?
Please help.
you should use the P() set expression like this:
sum({$<Defect_Date =P(Manufacturing_Date__c) >}Defect_Date)

Sort ALV grid by inverted date

I had a need to output TCURR table into ALV grid. All went fine but when user sorts table by "valid from" date (GDATU) strange things happened.
Sorting in ascending order behaves as sorting in descending order and vice versa. This is so because field GDATU contains date in inverted format and has domain GDATU_INV with the conversion routine INVDT which converts date on the fly. ALV grid shows the date correctly but sorting is done by inverted dates.
I solved it like this:
I declared table structure similar to TCURR and replaced GDATU_INV domain with simple DATUM.
I converted inverted dates into usual ones
I filled my table with the converted dates
After generating field catalog through FM LVC_FIELDCATALOG_MERGE according to TCURR structure I write to
CONVEXIT,
REF_TABLE,
DATATYPE,
DOMNAME
fields of the GDATU line values
'',
'',
'DATS',
'DATUM' respectively.
Is there more efficient and simple solution to this problem?
You should be able to use your new structure in LVC_FIELDCATALOG_MERGE, in stead of using TCURR which would mean that you don't have to overwrite the settings in the field catalog after the fact. But that's a pretty minor thing.
I don't think you had any choice but to use a structure with a data element that behaves the way you need it to.
Do look into the Simple ALV classes, though. (CL_SALV*) They are well documented and much easier to use than then now out-of-date ALV function modules. (Particularly generating the field catalog is a lot less hassle).

Sorting model instances with Globalize3

The problem seems trivial, but I can't find any reasonable solution. I have list of countries with translations stored in Globalize3 translation tables. How can I fetch the list of countries sorted by name?
Country name isn't stored directly in the model, but in separate table. Is there any reasonable way to sort the result other than manual sql query, or manualy sorting result table after AR query is complete?
Country.with_translations(I18n.locale).order('name') for current locale.
Edit:
You can also use fallbacks:
Country.with_translations(I18n.fallbacks[I18n.locale]).order('name')
Country.with_translations.order('name')

Resources