Sort Filter Run Prefix with function and currentTiddler

Hi,

I have a problem with the following code. Within the list-Widget the function getRPZ returns the correct value. But using this exact same function as an argument in the sort Filter Prefix doesn´t do anything. It somehow has to do something with the <<currentTiddler>> variable being differently interpreted in the two ways. I just don´t have a solution for giving the <<currentTiddler>> as a variable to the function.

Here is the code:

\function .up() [all[]] [.up1[]]
\function .up1() [all[]] :map:flat[listed[]tag[Fehlfunktion].up[]]

\function getLatestVMaßnahme(tiddler)
[list<tiddler>tag[Maßnahmenstand]!tag[In Umsetzung]sort[created]last[]] :map[list[]tag[Vermeidungsmaßnahme]]
\end

\function getABewertung()
[function[getLatestVMaßnahme]get[A-Bewertung]]
\end

\function getLatestEMaßnahme()
[list[]tag[Maßnahmenstand]!tag[In Umsetzung]sort[created]last[]] :map[list[]tag[Entdeckungsmaßnahme]]
\end

\function getEBewertung()
[function[getLatestEMaßnahme]get[E-Bewertung]]
\end

\function getBs()
[all[current].up[]] :filter[has[B-Bewertung]]
\end

\function getHighestBBewertung()
[function[getBs]get[B-Bewertung]maxall[]]
\end

\function getRPZ()
[<getHighestBBewertung>multiply<getABewertung>multiply<getEBewertung>]
\end

<$list filter="""[tag[Fehlfunktion]] :filter[list[]tag[Maßnahmenstand]count[]compare:number:gt[0]] :sort:number[<getRPZ>]""">

<$link /> - <<getRPZ>>

</$list>

What version of TiddlyWiki are you using? The latest release fixes some issues pertaining to the use of functions within filter run prefixes that sound like what you are experiencing.

1 Like

I am using Version 5.3.3

Thank you for the tip, gonna try to upgrade to 5.3.5 and will try again!

UPDATE:
The update changed the behaviour. The sort prefix is now principally working. Now I have another issue with the function getRPZ.

With version 5.3.3 this was working:

\function getRPZ()
[<getHighestBBewertung>multiply<getABewertung>multiply<getEBewertung>]
\end

With version 5.3.5 it only returns 0. But if I change the variables with actual numbers, it is doing something again:

\function getRPZ()
[<getHighestBBewertung>multiply[2]multiply[2]]
\end

Does anybody have an idea what that could be?

Thank you so much!

What do you expect list[] to return here? The list operator requires a parameter.

It should return the list of the <<currentTiddler>>, so it doesn´t need a parameter, am I correct? This also works as expected, if I use the function on its own.

Only as soon as I add the multiply operator, something goes unexpectedly wrong.

It is a bit difficult to follow the logic of your filters due to their nested nature, and names and thus relationships that I cannot comprehend.

If the functions returned the correct value before the upgrade, it suggests that they were relying on a value of currentTiddler being overriden by the filter run prefix. So you could try using the variable ..currentTiddler instead. However, this is close to a wild guess absent greater context of what the code is supposed to do.

This suggests that the problem lies in one of the two functions that you replaced with the hardcoded numbers.

Thanks for your input.

I found a solution, although I don´t exactly understand why it works.

This doesn´t work:

\function getRPZ()
[<getHighestBBewertung>multiply<getABewertung>multiply<getEBewertung>]
\end

This does work:

\function getRPZ()
[<getABewertung>multiply<getEBewertung>multiply<getHighestBBewertung>]
\end

Just changed the order of the functions being called.

Well I am happy it is working, hope it won´t break with a future upgrade :slight_smile: