Changing text based on a field value

Stimulsoft Reports.WEB discussion
JohnW
Posts: 103
Joined: Mon Nov 20, 2017 8:29 pm

Re: Changing text based on a field value

Post by JohnW »

It was asking for the first IIF to have a false return value. Said the parameter was missing, so I added it (' "") '). That resolved that error but now I get this error:

The error of compilation
The error of compilation is found in the 'Text' property of the 'Text_2' component:
Expression expected.

A curly bracket issue? It looks right to me otherwise.

Here is my/your current code

Code: Select all

{IIF((liqMast.LicenseTypeCode == "MBI" || liqMast.LicenseTypeCode == "BKR" || liqMast.LicenseTypeCode == "DIM" || liqMast.LicenseTypeCode == "REP"), "RENEWAL APPLICATION FOR REPRESENTATIVE'S ID CARD - $20","")
IIF((liqMast.LicenseTypeCode == "FWN" || liqMast.LicenseTypeCode == "MNB" || liqMast.LicenseTypeCode == "W32" || liqMast.LicenseTypeCode == "WLQ" || liqMast.LicenseTypeCode == "WLQBR" || liqMast.LicenseTypeCode == "WMB" || liqMast.LicenseTypeCode == "WMBBR" || liqMast.LicenseTypeCode == "WWN" || liqMast.LicenseTypeCode == "WWNMFR" || liqMast.LicenseTypeCode == "LQRMFR"),"RENEWAL APPLICATION FOR SALES PERSON'S ID CARD - $35", ""))}



Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Changing text based on a field value

Post by Alex K. »

Hello,

Please check the following expression:

Code: Select all

{IIF((liqMast.LicenseTypeCode == "MBI" || liqMast.LicenseTypeCode == "BKR" || liqMast.LicenseTypeCode == "DIM" || liqMast.LicenseTypeCode == "REP"), 
"RENEWAL APPLICATION FOR REPRESENTATIVE'S ID CARD - $20","")}

{IIF((liqMast.LicenseTypeCode == "FWN" || liqMast.LicenseTypeCode == "MNB" || liqMast.LicenseTypeCode == "W32" 
|| liqMast.LicenseTypeCode == "WLQ" || liqMast.LicenseTypeCode == "WLQBR" || liqMast.LicenseTypeCode == "WMB" 
|| liqMast.LicenseTypeCode == "WMBBR" || liqMast.LicenseTypeCode == "WWN" || liqMast.LicenseTypeCode == "WWNMFR" || liqMast.LicenseTypeCode == "LQRMFR"),
"RENEWAL APPLICATION FOR SALES PERSON'S ID CARD - $35", "")}
Thank you.
JohnW
Posts: 103
Joined: Mon Nov 20, 2017 8:29 pm

Re: Changing text based on a field value

Post by JohnW »

I have tried the code. I get 5 instances of this error

The error of compilation
The error of compilation is found in the 'Text' property of the 'Text_2' component:
Expression expected.

I looked at the code output and this is the Sub that is created.

Code: Select all

   
Public Sub Text_2__GetValue(ByVal sender As Object, ByVal e As Stimulsoft.Report.Events.StiGetValueEventArgs)
            'CheckerInfo: Text Text_2
            e.Value = ToString(sender, IIF((liqMast.LicenseTypeCode == "MBI" || liqMast.LicenseTypeCode == "BKR" || liqMast.LicenseTypeCode == "DIM" || liqMast.LicenseTypeCode == "REP"), 
"RENEWAL APPLICATION FOR REPRESENTATIVE'S ID CARD - $20",""), true) + ""&Microsoft.VisualBasic.ChrW(13)&Microsoft.VisualBasic.ChrW(10)&Microsoft.VisualBasic.ChrW(13)&Microsoft.VisualBasic.ChrW(10) + ToString(sender, IIF((liqMast.LicenseTypeCode == "FWN" || liqMast.LicenseTypeCode == "MNB" || liqMast.LicenseTypeCode == "W32" 
|| liqMast.LicenseTypeCode == "WLQ" || liqMast.LicenseTypeCode == "WLQBR" || liqMast.LicenseTypeCode == "WMB" 
|| liqMast.LicenseTypeCode == "WMBBR" || liqMast.LicenseTypeCode == "WWN" || liqMast.LicenseTypeCode == "WWNMFR" || liqMast.LicenseTypeCode == "LQRMFR"),
"RENEWAL APPLICATION FOR SALES PERSON'S ID CARD - $35", ""), true)
        End Sub
JohnW
Posts: 103
Joined: Mon Nov 20, 2017 8:29 pm

Re: Changing text based on a field value

Post by JohnW »

Also as you can see I am getting the Syntax Error in the lower left corner of the text box. Should I be putting this code in a variable first or does it make a difference?
Ashampoo_Snap_2018.02.06_07h14m02s_005_.png
Ashampoo_Snap_2018.02.06_07h14m02s_005_.png (31.98 KiB) Viewed 6145 times
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Changing text based on a field value

Post by Alex K. »

Hello,

Please send us your report with test data for analysis.

Thank you.
JohnW
Posts: 103
Joined: Mon Nov 20, 2017 8:29 pm

Re: Changing text based on a field value

Post by JohnW »

How do I send the file you if I don't want it on the forum?
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Re: Changing text based on a field value

Post by Edward »

Hi John,

Please email it to support[at]stimulsoft.com

Thank you,
Edward
JohnW
Posts: 103
Joined: Mon Nov 20, 2017 8:29 pm

Re: Changing text based on a field value

Post by JohnW »

I have tracked part of the issue. It appears the code you were providing is C#. I use VB.Net So when I convert to VB see below it partially works.

It does not seem to like having a second IIF statement. If I delete the second IIF it runs. If I put it back in it fails

NOTE: The expression editor says 'OR" statements are not valid even though they do run and gives an error message in the lower left. A bug?

Here is the code I have at the moment

Code: Select all


{IIF((liqMast.LicenseTypeCode = "MBI" OR liqMast.LicenseTypeCode = "BKR" OR liqMast.LicenseTypeCode = "DIM" OR liqMast.LicenseTypeCode = "REP"), 
"RENEWAL APPLICATION FOR REPRESENTATIVE'S ID CARD - $20","")}

{IIF((liqMast.LicenseTypeCode = "FWN" OR liqMast.LicenseTypeCode = "MNB" OR liqMast.LicenseTypeCode = "W32" 
OR liqMast.LicenseTypeCode = "WLQ" OR liqMast.LicenseTypeCode = "WLQBR" OR liqMast.LicenseTypeCode ="WMB" 
OR liqMast.LicenseTypeCode ="WMBBR" OR liqMast.LicenseTypeCode = "WWN" OR liqMast.LicenseTypeCode ="WWNMFR" OR liqMast.LicenseTypeCode = "LQRMFR"),
"RENEWAL APPLICATION FOR SALES PERSON'S ID CARD - $35", "")}

JohnW
Posts: 103
Joined: Mon Nov 20, 2017 8:29 pm

Re: Changing text based on a field value

Post by JohnW »

I have this working now. In VB the IIF also does not like multi-line statements. It needs to be all on one line.

It would be nice if you could add an IF-THEN ELSE statement to the programming shortcuts. Its pretty commonly used in coding so I am sure the user base would like it.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Changing text based on a field value

Post by Alex K. »

Hello,

We have fixed some problems with VB language.
We have added these tasks to our to-do list. We will try to fix it in the near future.

Thank you.
Post Reply