This can be solved by determining the length of the string first with the ‘length’ function. Use the integer you get out of this function as inputparameter when calling the function ‘substring’, like:
substring($yourstring, 0 , (length – 1))
You can use a "Change Variable” action:
if endsWith($Variable, ',')
then substring($Variable, 0, length($Variable) -1)
You use the microflow action: "Change Variable” with the following configuration
This removes the last character from your string.
If you only need to remove it when it is a comma, take a look at this page: https://docs.mendix.com/refguide7/string-function-calls