Welcome to Knowage Q&A, where you can ask questions and receive answers from other members of the community.
0 votes
1 view

I am using Knowage6. I have created an analytical driver 'Date' which should by default show end of current financial year end. (In India financial year is from April to March).

I have written following Groovy code for LOV and selected this LOV for analytical driver. While preview on the LOV it shows correct Date but while executing the document, the document does not open. Rather it throws some errors.

Groovy Code:

Date now = new Date();
int year =now.getYear()+1900;
if (now.getMonth()>2) year=year+1;
String toReturn = '31/03/'+ year.toString();
returnValue(toReturn);

Error:

syntax error (#74)

how to debug this error. I tried other syntax using Javascript also. It is the same problem; while the value is shown during TEST of LOV, it does not show while running the document.

in Analytical Driver by (310 points)

1 Answer

+1 vote

Hi,

I suggest you two different solutions hoping you will find them helpfull.

1. You can keep the script you have written and change the type of the analytical driver from 'Date' to 'String'.

Obviously in this way you will not have the possibility of choosing the value of the parameter from the calendar.

Please notice that if you choose this solution you may change the single quote marks to double quote marks as follow:

Date now = new Date();
int year =now.getYear()+1900;
if (now.getMonth()>2) year=year+1;
String toReturn = "31/03/"+ year.toString();
returnValue(toReturn);

This is due to a bug we will fix as soon as possible: https://www.knowage-suite.com/jira/browse/KNOW-16

2. The second possibility, if you want to use an AD of date type is to add the date format to your string.

I write you down an example which you can use to create your solution:

Date now = new Date();

int year =now.getYear()+1900;

if (now.getMonth()>2) year=year+1;

returnValue("31/03/"+year+"#dd/MM/yyyy");

by
...