Hello Aleksandr.
This ticket is somewhat related to How to use a custom function to localize month formatting in XRCrossTabCell.
I have a XRCrossTab
defined and I want to set up expression bindings for some of its cells to call my custom function called DateTimeToMonthNameAndYear
. This function consumes two arguments - the first one is an object with ILocalization
interface (so not a simple type), the second one is DateTime value.
The ILocalization
object contains some regional settings of the current user and is passed to the report as its parameter.
This report parameter is then re-bound as the cross-tab parameter.
The custom function is called within the context of cross-tab as expected but the operand value is null.
If I try the same approach with the string value parameter (report parameter is bound to cross-tab parameter, proper custom function is called) then the parameter string value is available inside the custom function.
I have attached simple sample project to demonstrate the problem.
Interesting lines are:
CodeCustomFunctions.Register(new DateTimeToMonthNameAndYear()); // accepts ILocalization and DateTime
CustomFunctions.Register(new MyStringFunction()); // accepts string value
...
NewParameter(report, "Localization", typeof(ILocalization), Session); // the Session is object with ILocalization interface
NewParameter(report, "MyStringValue", typeof(string), "OK_FOO_BAR"); // string value
...
var crossTab = new XRCrossTab();
...
crossTab.Parameters.AddRange(
[
new XRControlParameter("groupName", null, "IDPRACPOMER"),
new XRControlParameter("MyStringValue", Report.Parameters["MyStringValue"]), // rebound parameter to cross-tab
new XRControlParameter("Localization", Report.Parameters["Localization"]) // rebound parameter to cross-tab
]);
...
crossTab.Cells[0, 2].ExpressionBindings.Add(new("BeforePrint", "Text", "'PARAM: ' + ?MyStringValue + '\nFUNC1: ' + MyStringFunction(?MyStringValue) + '\nFUNC2: ' + DateTimeToMonthNameAndYear(?Localization, [MESIC])")); // call custom functions
The current result is:
String value parameter (OK_FOO_BAR) can be referenced successfully both from XRLabel
or from a custom function.
Object value parameter is not passed to the custom function so it cannot be used there (thus ERROR_NO_LOCALIZATION).
The expected result is to display OK_LOCALIZATION so the ILocalization object is available in my custom function.
What am I doing wrong?