Use of custom variables in data bands.

Stimulsoft Reports.JS discussion
Post Reply
rjorge99
Posts: 36
Joined: Tue Feb 28, 2023 6:24 pm

Use of custom variables in data bands.

Post by rjorge99 »

Hi,

I have been working with custom variables, but while using them in the data bands, I have encountered some issues.

These variables refer to information found within the XML assigned to these data bands. For example, I have a variable called "xDescPro", whose value refers to "IIF(Trim(cab.txt_ing) == 'true', Trim(pfr.desc_prod2), Trim(pfr.desc_prod))", with "pfr" being each of the records in my XML.

This is done because these custom variables are used in other fields of the data band, such as the custom variable "xDescrip" whose value is: "IIF( !string.IsNullOrEmpty(Trim(IIF(cab.txt_ing == 'true', pfr.desc2, pfr.desc1))), IIF( !string.IsNullOrEmpty(xDescPro), '', '' ) + Trim(IIF(cab.txt_ing == 'true', pfr.desc2, pfr.desc1)), '' ) ". As you can see in the "xDescrip" variable, it internally uses the "xDescPro" variable.

The problem is that these variables take the value of the first record in my data and do not update automatically. That is, as seen in the provided example, when using the "xDescPro" variable, it assigns the resulting value of my first record in my XML, "55", instead of taking the corresponding value for each of the records, expecting "Other value" for the second record, but as seen in the example, it uses "55".
Untitled.png
Untitled.png (12.5 KiB) Viewed 1506 times
Is there a way to handle this using custom variables within the data band?


Other problem that I dont know how to solve with the Header band, is there a way to enable a textbox if at least one of the records in my data has information, for example, in my header I use something like:

Code: Select all

 {(decimal)dat.dctos == 0 && dat.conmed == "0" && IsNullOrEmpty(Trim(pfr.cve_prodk))} 
to enable a field, but that only works if the first field of my data has information in "pfr.cve_prodk". Is there a way to show it if at least one record has information?

Thanks
Lech Kulikowski
Posts: 7292
Joined: Tue Mar 20, 2018 5:34 am

Re: Use of custom variables in data bands.

Post by Lech Kulikowski »

Hello,

Please send us a sample report with test data for analysis.

Thank you.
rjorge99
Posts: 36
Joined: Tue Feb 28, 2023 6:24 pm

Re: Use of custom variables in data bands.

Post by rjorge99 »

Hi,

Sorry, I forgot to attach the example.
CustomVariables.zip
(5.05 MiB) Downloaded 152 times
Thanks
Lech Kulikowski
Posts: 7292
Joined: Tue Mar 20, 2018 5:34 am

Re: Use of custom variables in data bands.

Post by Lech Kulikowski »

Hello,

Unfortunately, it is not possible for variables, its initialized once before report rendering.
You can use the same expression as in variables in the Text component.

Thank you.
Post Reply