1. Ben Antwi
  2. Valentina Studio
  3. Freitag, Oktober 28 2022, 02:45 PM
  4.  Abonnieren via E-Mail
Is it possible to pass value of a variable to Valentina Report? Example item_no = 10 which is not from database but it's just a variable in a python script. Will item_no be referenced as a text field in report editor of Valentina Studio?
Kommentar
There are no comments made yet.
Ben Antwi Akzeptierte Antwort
Please could you check your private message box.
Kommentar
There are no comments made yet.
Sergey Pashkov Akzeptierte Antwort
Hello Ben,

A license is required to generate reports from the Python application.
Without a license, application works for 10 minutes in demo mode.
Referenzen
  1. https://valentina-db.com/en/buy-reports-adk/product/18-valentina-reports-adk
Kommentar
There are no comments made yet.
Ben Antwi Akzeptierte Antwort
Please is it because I'm using a demo version of the valentina studio?
Kommentar
There are no comments made yet.
Ben Antwi Akzeptierte Antwort
Hi Sergey
When I run my .exe application and I leave it idle for some time the valentina report does not work.
Kommentar
There are no comments made yet.
Ben Antwi Akzeptierte Antwort
@Sergey I figured it out. I omitted a, before GROUP_CONCAT
Kommentar
There are no comments made yet.
Ben Antwi Akzeptierte Antwort
This is the example that returns the error:


SELECT p. name, p. address, lt.start_date,end_date GROUP CONCAT('C:\\Users\\my-pc\\Desktop\\test\\img\\' || ' picture.png') As full_path FROM first_table p
JOIN second_table lt
ON lt.id_no = p.id_no
WHERE p.id_no = '123'
Kommentar
There are no comments made yet.
Ben Antwi Akzeptierte Antwort
Hi Sergey
Is it possible to run a join query in valentina pro because I tried and it returning an error?
Kommentar
There are no comments made yet.
Sergey Pashkov Akzeptierte Antwort
I would add a default value for the parameter to see how it is printed from Valentina Studio.
So you added an expression control containing p_count_no parameter?
With a default value, you can test its printing.
Kommentar
There are no comments made yet.
Ben Antwi Akzeptierte Antwort
I have already set this in valentina studio
Anhänge
Kommentar
There are no comments made yet.
Ben Antwi Akzeptierte Antwort
count_info is a database field with type as text.
So all I want to do is to check if the field is not empty then my_counter is increased by 1.
Kommentar
There are no comments made yet.
Ben Antwi Akzeptierte Antwort
Yes please the value set to parameter not printed in report
Kommentar
There are no comments made yet.
Sergey Pashkov Akzeptierte Antwort
You can pass a value - it can be, for example, a variable, literal, or function call that returns a value
report.setParameterValue( 'p_item_no', item_no )
report.setParameterValue( 'p_item_no', '5' )
report.setParameterValue( 'p_item_no', my_function(5) )

So what exactly doesn't work? Is the value set to parameter not printed?
Kommentar
There are no comments made yet.
Ben Antwi Akzeptierte Antwort
The user function details are below :



def my_counterfunction(self) :
global my_counter

if count_info[0][0] != " ":
my_counter = my_counter + 1



Can I just call the user defined function in the report or just the variable name my_counter?
Kommentar
There are no comments made yet.
Ben Antwi Akzeptierte Antwort
The variable name is used in a user defined method. Is it possible to call the method in the valentina report because the method does the math and pass the result to the variable my_counter. And if possible how can I do that please?
Kommentar
There are no comments made yet.
Ben Antwi Akzeptierte Antwort
Hi Sergey

I tried to do as instructed above but it did not work.
However, the variable name in my python script is a global variable and it is called my_counter.
Kommentar
There are no comments made yet.
Sergey Pashkov Akzeptierte Antwort
Hello,

Add an Expression control to the report, different types of expression languages can be used

  • Text With Macros: $P(p_item_no)
  • JavaScript: $P('p_item_no')


Define a default value on the Parameters tab

In Python:
report.setParameterValue( 'p_item_no', item_no )
Anhänge
Kommentar
There are no comments made yet.
  • Seite :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.