Hi,
We have a custom user macro that is no longer working and we are not able to fix the code.
This user macro compute dates based on current date
Here is the code:
## Macro title: Relative Date
## Macro has a body: No
## Body processing: No macro body
##
## This user macro compute date base on current date and the parameters
## @Param type:title=Type|type=enum|required=true|enumValues=Day,Week,Month,Year
## @Param increment:title=Increment|type=int|required=true|desc= Increment value
## @Param rounded:title=Round|type=enum|required=false|enumValues=Up,Down
## declare variables and initialize as java date objects with current date
#set ($newDate = $action.dateFormatter.calendar)
#set($increment = $generalUtil.convertToInteger("$paramincrement"))
$newDate.setTime($content.currentDate)
## https://docs.oracle.com/javase/7/docs/api/constant-values.html#java.util.Calendar.WEEK_OF_MONTH
##Year
#if( $paramtype == "Year" )
$newDate.add(1, $increment)
#if( $paramrounded == "Up")
$newDate.set(6, $newDate.getActualMaximum(6))
#elseif( $paramrounded == "Down" )
$newDate.set(6, 1)
#end
##Month
#elseif( $paramtype == "Month" )
$newDate.add(2, $increment)
#if( $paramrounded == "Up")
$newDate.set(5, $newDate.getActualMaximum(5))
#elseif( $paramrounded == "Down" )
$newDate.set(5, 1)
#end
##Week
#elseif( $paramtype == "Week" )
$newDate.add(4, $increment)
#if( $paramrounded == "Up")
$newDate.set(7, $newDate.getActualMaximum(7))
#elseif( $paramrounded == "Down" )
$newDate.set(7, 1)
#end
##Day
#elseif( $paramtype == "Day" )
$newDate.add(6, $increment)
#end
<time datetime="$action.dateFormatter.formatGivenString("yyyy-MM-dd", $newDate.time)" class="date-upcoming">$action.dateFormatter.formatGivenString("dd MMM yyyy", $newDate.time)</time>
The type of error messages we see in Confluence now wherever the macro is used:
$newDate.setTime($content.currentDate) $newDate.add(2, $increment) $newDate.set(5, $newDate.getActualMaximum(5))
Anyone as an idea what is wrong in the code? It used to work fine until just recently...
Thanks!
Was Confluence recently updated? This is a "feature" introduced in 7.19.x, more information about the bug and a workaround here: https://jira.atlassian.com/browse/CONFSERVER-82741?src=confmacro
Similar questions have been asked throughout the community - User macro not working as expected after version u... (atlassian.com)
The workaround of adding the JVM param works on Confluence 8.3 on my side, it should fix your issue. Confluence version do not fix the issue but the workaround does.
-Dmacro.required.velocity.context.keys=generalUtil,bootstrap,containerContext,action,req,content
Thx @Matt
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you! The workaround worked for us. Updating Confluence did not resolve the issue
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.