Page 1 of 1

How to Use Variable Functions in EventCode

Posted: Fri Jan 18, 2008 2:47 am
by Markus Weiß
Hi,

i tried to use a dictionary variable function in the Report.BeginRender event to dynamically create a display string for my report. With normal variable all is working as expected, but with function variables i'getting the expression code an not the value. How do i get the correct value an not the expression?

For example the i attached my code. The variables were:

PersonResponsible

Code: Select all

Test
ManagedDisplay

Code: Select all

IIF(Managed="1","Managed",IIF(Managed="0","Unmanaged","All"))
Parameters2Show

Code: Select all

PersonResponsible;ManagedDisplay
ParameterNames2Show

Code: Select all

Resource Owner;Management State
The Result for ParametersDisplayLine is something like:

Code: Select all

Resource Owner=Test, Management State=IIF(Managed="1","Managed",IIF(Managed="0","Unmanaged","All"))
The Code in the Report.BeginRender event is:

Code: Select all

Dim strParameters() as String = Parameters2Show.Split(";"c)
Dim strParameterNames() as String = ParameterNames2Show.Split(";"c)
Dim i as Integer

ParametersDisplay = ""
ParametersDisplayLine = ""

For i = 0 To strParameters.GetUpperBound(0)
	If Me.Dictionary.Variables(strParameters(i)).Value.Length > 0 Then
		If ParametersDisplay.Length > 0 Then
			ParametersDisplay = ParametersDisplay & vbCrLf & strParameterNames(i) & vbTab & "= " & Me.Dictionary.Variables(strParameters(i)).Value
			ParametersDisplayLine = ParametersDisplayLine & ", " & strParameterNames(i) & "=" & Me.Dictionary.Variables(strParameters(i)).Value
		Else
			ParametersDisplay = strParameterNames(i) & vbTab & "= " & Me.Dictionary.Variables(strParameters(i)).Value
			ParametersDisplayLine = strParameterNames(i) & "=" & Me.Dictionary.Variables(strParameters(i)).Value
		End If
	End If
Next

How to Use Variable Functions in EventCode

Posted: Tue Jan 22, 2008 5:44 am
by Markus Weiß
Any suggestions ? Somebody?

Thanks

How to Use Variable Functions in EventCode

Posted: Tue Jan 22, 2008 6:19 am
by Edward
Please use the following code:

Code: Select all

Me.Item("MyVariableWithExpression").ToString
In the Dictionary of the report template the expression representation is stored, but in runtime variable can be evaluated as the code above. Expression may be calculated with using of the variables with default values without "Functions" when they have usual default values.
But here is one nuance. Variables order is important in the Dictionary. In the order of their representation they will be created. So please pay attention to it.

Thank you.