Sort order in HtmlAdvanced portlet of Portal 2

Hello.

I am not being able to sort the lines in a portlet of the type “HtmlAdvanced”, which is fed by an SQL query (SELECT). I would expect that the lines were shown in the same order that they appear if I execute the “SELECT” in Azure Data Studio and SQL Management Studio, ie, according to the “ORDER BY” clause, but whichever this is, the lines always appear sorted in the same way, not related with the “ORDER BY” clause, and I don’t even figure out what sort key is used.

SELECT TOP 100 PERCENT Id
, [PortalNovacura].[dbo].NotAlertHtm(Texto, Url, imgUrl, imgPosition, imgWidth, imgHeight) as Htm
FROM [PortalNovacura].[dbo].[Noticias]
WHERE tipo=‘ale’ AND TRIM(Texto)<>‘’
AND ISNULL(Enabled,1)<>0 AND (DtExpira is NULL OR DtExpira >= getdate())
ORDER BY Id DESC

[PortalNovacura].[dbo].NotAlertHtm(…) is a SQL function that builds the HTML code shown in each line, using the “configuration data” that is shown in the top table (NOTICIAS BO TABLE), which uses an SQL on the same table. The WHERE clause serves to select only the records that are of the type intended and are enabled.

Note that if the “ORDER BY” was respected the lines on the “ALERTA” table would show with the following order:

  1. “Acessos à A3 …” (Id=6)
  2. “Proteção Civil …” (Id=4)
  3. “Câmara de Lisboa …” (Id=3)

But, as yo can see, it shows first the Id=3, then Id=4 and then Id=6. The same happens when I use the a column that contains de datetime of the last update, either with ASC or DESC, and this sort order is equivalent of SORT BY Id with the current data.

Anyone has any clue on what is the cause of this behavior and what can de done so I can have control over the sort order?

Thank you.
Regards.

Anyone has any clue on what is the cause of this behavior and what can de done so I can have control over the sort order?

Thank you.
Regards.

Hi,
It sounds like one of the downsides to using html rather than the table portlet. It behaves a bit weird due to its nature. Not sure if this would work:

What is the reason for not wanting to use the table portlet? I do get that it is not always what you need but it is interesting to hear your thougths on that.

Can I use HTML in a table portlet? If yes, then I think I can use a table.

Hi,

i think there is a bug with using Datasource: Database and order by clause (honestly there are a few bugs with Datasource: Database so i just go for Workflow by default)

Just create a flow (Machine/Datasource), put the same code in a machine step, use Datasource: Workflow and it should work.

Hope this helps!

B R
Ivan

Oh cool, nice if it works as expected just by using a workflow as a data source. Good catch Ivan

Jose Mario, there are some very limited html-options in the table portlet. Like bold text or line break, but not very sophisticated.

I have just changed the Datasource to a workflow that just executes the same SQl code and it works. Strange… Well, but the important thing is that the problem is solved. That you, guys. @ivstde and @OlaCarlander .