While generating a custom report in PDF format a field is populating unwanted values. Values which are not present in the task.
A custom field is simply not selected at all. (Field is not used). It is not a mandatory field. So a default value is being populated. But that is not the desired output.
Is there any way to keep a hyphen (-) instead of populating default values.
Because your question is tagged with "midori", I suspect you are using the Better PDF Exporter app.
If so, I'm a developer working on it and happy to help, but I need more details:
Hi Aron,
Thank you for getting back!
Yes, we use Better PDF Exporter app.
Recovery timeline is the custom field.
"Recovery Timeline" is EMPTY - is the condition in the query.
Example of what the value is in the below picture
as per the query, the value of the field should be empty in the pdf file
but it's populating current date of the system. If the above condition is used in the query.
If that condition is not being used it is populating Recovery timeline date of the previous project that is rendered in the PDF.
But the expected output is a hyphen (-) or a blank column.
#set($recoveryTimeline = $customFieldManager.getCustomFieldObjectByName("Recovery Timeline"))
#set($recoverytimelinevalue = $issue.getCustomFieldValue($recoveryTimeline))
<fo:block>
$userDateTimeFormatter.withStyle($dateTimeStyle.DATE).format($recoverytimelinevalue)
</fo:block>
is the format in which I'm calling the value.
Please let me know if you need more details.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It's just a quick idea, but if you can find a good condition to decide if you want to see the actual value or a hyphen in the output, then of course you could just:
#set($recoverytimelinevalue = $issue.getCustomFieldValue($recoveryTimeline))
<fo:block>
#if(... your condition comes here ...)
## export the value
$userDateTimeFormatter.withStyle($dateTimeStyle.DATE).format($recoverytimelinevalue)
#else
## export the hyphen
-
#end
</fo:block>
So, the question what would be the correct condition?
As a dumb one, I could imagine that you check if the $recoverytimelinevalue holds a time value that is older than an hour. If it is not, then it is the "current date", so you render the hyphen. Otherwise you render the actual value.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Aron,
I still have issues with the code I wrote. Can you please help me out.
<fo:table-row>
<fo:table-cell padding="1mm" border-width="1mm" border-style="solid">
<fo:block font-weight="bold"> Recovery Timeline </fo:block>
</fo:table-cell>
#set($recoveryTimeline = $customFieldManager.getCustomFieldObjectByName("Recovery Timeline"))
#set($recoveryimelinevalue = $issue.getCustomFieldValue($recoveryTimeline))
#if($recoveryimelinevalue == $currentdate - 1)
<fo:table-cell padding="1mm" border-width="1mm" border-style="solid" number-columns-spanned="7">
<fo:block space-before="1mm">
<fo:block>
-
</fo:block>
</fo:block>
</fo:table-cell>
#else
<fo:table-cell padding="1mm" border-width="1mm" border-style="solid" number-columns-spanned="7">
<fo:block space-before="1mm">
<fo:block>
$userDateTimeFormatter.withStyle($dateTimeStyle.DATE).format($recoveryimelinevalue)
</fo:block>
</fo:block>
</fo:table-cell>
#end
</fo:table-row>
This is the block in the custom report I have issues with.
I am seeing that the recovery timeline value is sometimes populating the value of the old project.
For example in the report
there is an xyz project with recovery timeline value 31/Dec/19 which is populated in the first column
and a project abc which doesn't have any recovery timeline value specified in the issue
but it's still showing 31/Dec/19
I am not sure why.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In the Velocity language, you cannot assign NULL to a variable. When you try that, the variable will keep its previous value!
For example:
#set($foo = 2)
#set($foo = $bar) ## if bar is null, then this code will not do anything
## at this point foo still equals to 2!
So, the trick is to assign an empty string and do a check, something like this:
#set($recoveryimelinevalue = "") ## we assign an empty string
#set($recoveryimelinevalue = $issue.getCustomFieldValue($recoveryTimeline))
#if($recoveryimelinevalue != "")
## in this block we can know that the custom field had an actual value
#else
## the custom field value was NULL
#end
Can you follow me?
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.