Page 1 of 2
Variable Initialization
Posted: Thu Sep 19, 2013 9:23 pm
by Daniel Schmitz
Hello.
I'm trying to initialize a variable using the "expression" option, and setting it's value to a field in my Bussiness Objects.
But when I run my report, I get an generic error message.
My code seems like:
myIntVar = MyBussinessObject.AnIntValue
Thanks.
Re: Variable Initialization
Posted: Fri Sep 20, 2013 6:39 am
by HighAley
Hello.
Where do you try to initialize variable with this expression?
Please, describe your issue more detailed.
Thank you.
Re: Variable Initialization
Posted: Mon Sep 23, 2013 11:45 am
by Daniel Schmitz
Hello.
I'm trying to initialize the variable in the New Variable window.
I've attached a printscreen of what I'm trying to do.
Thanks.
Re: Variable Initialization
Posted: Mon Sep 23, 2013 12:47 pm
by HighAley
Hello.
Please, try to enable the Read Only option. Then the variable will be calculated each time.
Thank you.
Re: Variable Initialization
Posted: Mon Sep 23, 2013 1:41 pm
by Daniel Schmitz
Hello.
Thanks for the quickly reply.
It worked, but sometimes this variable needs to be reassigned, as I use it as a counter.
So in my case, I cannot set it as Read Only.
What can I do?
Thanks.
Re: Variable Initialization
Posted: Mon Sep 23, 2013 2:20 pm
by HighAley
Hello, Daniel.
You could change the variable's value in a BeforePrint event of a Data Band or some where else. And don't use the init expression.
Thank you.
Re: Variable Initialization
Posted: Mon Sep 23, 2013 2:59 pm
by Daniel Schmitz
Hello.
Yes, I'm changing it's value in the BeforePrint event of my PageHeader, in this case counting the number of pages, incrementing it's value by 1.
But I need to initialize it by a value that comes from my bussiness object.
So, if my BO has the value 5, I need start counting from page 6: 6, 7, 8, ...
Sorry if I was not so clear before.
Thanks.
Re: Variable Initialization
Posted: Mon Sep 23, 2013 7:56 pm
by Daniel Schmitz
Hello.
I was debugging my code, searching for something, and the error I got in the file I've attached.
I got the same error debugging your sample code.
Another solution I've tryied was to use the PageNumber property.
It worked fine, but I could'nt get how do I reset the counter, as I need it to happen when PageNumber get equals to a parameter I have.
Thanks.
Re: Variable Initialization
Posted: Wed Sep 25, 2013 6:00 am
by HighAley
Hello, Daniel.
Daniel Schmitz wrote:I was debugging my code, searching for something, and the error I got in the file I've attached.
I got the same error debugging your sample code.
It seems that you are using partial trust mode. Please, try to set next option:
Code: Select all
StiOptions.Engine.FullTrust = false;
Daniel Schmitz wrote:Another solution I've tryied was to use the PageNumber property.
It worked fine, but I could'nt get how do I reset the counter, as I need it to happen when PageNumber get equals to a parameter I have.
You could try to use
Reset Page Number property of the Page Header.
Thank you.
Re: Variable Initialization
Posted: Wed Sep 25, 2013 9:53 pm
by Daniel Schmitz
Hello.
I tried to set FullTrust = false, but now the report don't load any of my data.
I've also tried to use the Reset Page Number property in the AfterPrint event of my PageHeaderBand1, with a text displaying the PageNumber in it:
if(PageNumber == 10)
{
PageHeaderBand1.ResetPageNumber = true;
}
else
{
PageHeaderBand1.ResetPageNumber = false;
}
But for some reason, PageNumber == 10 it's getting true when my text is displying 8.
Is there something wrong?
Thanks