Page 1 of 1

I cannot set GuidList type parameter on runtime

Posted: Fri Mar 15, 2024 12:43 pm
by ruen
Hello,

I am currently working with a report that incorporates a variety of parameters. My objective is to execute the report with predefined values. While I am able to assign values to all parameter types without issue, I encounter difficulties specifically with the GuidList type.

Code: Select all

var stiVariable = stiReport.Dictionary.Variables[anyVariable];
For parameters of boolean, string, and Guid types, the assignment operates as expected:

Code: Select all

stiVariable.ValueObject = true/false;
stiVariable.ValueObject = "string";
stiVariable.ValueObject = new Guid(guidValue);
However, when attempting to assign a GuidList type as shown below:
stiVariable.ValueObject = new GuidList(new Guid(guidValue));

I've noticed that there is no implementation of any kind of list object in ValueObject's setter (StiVariable.cs => private void SetValue(object value))
The operation completes without throwing any exceptions, yet the stiVariable.ValueObject and Value properties remain null. This issue persists despite the necessity to run the report with multiple GUID selections.

Would you have any insights or suggestions to resolve this matter?

Thanks.

Re: I cannot set GuidList type parameter on runtime

Posted: Sun Mar 17, 2024 7:52 am
by ruen
I saw a post about this topic 10 years ago
viewtopic.php?t=38427

Is the same situation still present?

Re: I cannot set GuidList type parameter on runtime

Posted: Mon Mar 18, 2024 9:45 pm
by Lech Kulikowski
Hello,

Please try to check the following code:

Code: Select all

report.Dictionary.Variables.Add(new StiVariable("", "Variable1", "Variable1", "", typeof(StringList), "", false, StiVariableInitBy.Value, true, new StiDialogInfo(StiDateTimeType.Date, "", true, new string[] {
                    "1",
                    "2"}, new string[] {
                    "1",
                    "2"}), null, false, StiSelectionMode.FromVariable));
Thank you.

Re: I cannot set GuidList type parameter on runtime

Posted: Tue Mar 19, 2024 7:22 am
by ruen
Hello, Thank you Lech.
It works!

You don't have to add new variable, if you want to change existing variable on the fly, just re-assign StiDialogInfo.
You should set your parameters as string[] even your variable type is GuidList.

Make sure Variable's readonly parameter is false.

Code: Select all

stiVariable.DialogInfo = new StiDialogInfo(StiDateTimeType.Date, "", true, new string[] {
                    "1",
                    "2"}, new string[] {
                    "1",
                    "2"})

Re: I cannot set GuidList type parameter on runtime

Posted: Tue Mar 19, 2024 6:37 pm
by Lech Kulikowski
Hello,

You are welcome.