Changing text based on a field value

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

Changing text based on a field value

Post by JohnW »

My need is for a generic report to have it text in a text component changes based on a value elsewhere in the report.

I have looked at the IIF and Switch statements. Those kind of work. My issue is I have say 50 values to equal one text variation and say 15 for another and 10 for yet another text variation.

What is the recommended process for doing something like this. I recall being able to use an IN type statement in Crystal Reports formulas but I am not seeing something like that here.

Suggestions?
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Changing text based on a field value

Post by HighAley »

Hello, John.

You could use any C# or VB.NET expression in your report.
As a way you could use the Conditions and set the Assign Expression option there.

Please, send us any sample if you still need our help.

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

Re: Changing text based on a field value

Post by JohnW »

Thanks I will give it try with the VB.net coding. If I can just get those curly braces in the correct spot.<smile>. If I get stuck I may need to send a sample.
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Changing text based on a field value

Post by HighAley »

Hello, John.

Could you describe your task more detailed with samples and we will try to find a better solution for you?

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

Re: Changing text based on a field value

Post by JohnW »

HighAley

I need to create permits. The permit type text changes based on the license type code. A single permit may be related to a group of license type codes. Each group can have varying numbers of codes. So for example:

Permit Text 1 if License Type Code is in group with LTC1,LTC2,LTC7,LTC22, etc.

Permit Text 2 if License Type Code is in group with CTR1,LTC5,LTC6, BC1, etc.

So it needs to print the permit text based on the license type code.

Clear as mud as they say, but that is what I need to code into a report expression somewhere. In Crystal Reports I was able to use formula field to create the logic, I am guessing I need to get that logic into an Expression
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,

You can use IIF() function:
{IIF(License Type = YourCondition, YourTrueValue, YourFalseValue)}

Please send us a test data, we will try to prepare a sample for you.

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 got redirected from report building. I am again working on them. Based on the earlier response I have tried creating this code, it is not working. It may be the IIF does not the IN statement

Code: Select all

{IIF ({liqMast.LicenseTypeCode} IN ("MBI","BKR","DIM","REP"),"RENEWAL APPLICATION FOR REPRESENTATIVE'S ID CARD - $20"),)}
{IIF ({liqMast.LicenseTypeCode} IN ("FWN", "MNB", "W32", "WLQ", "WLQBR", "WMB", "WMBBR", "WWN", "WWNMFR", "LQRMFR"),"RENEWAL APPLICATION FOR SALES PERSON'S ID CARD - $35"),)}
Any suggestions. I do have a number of these to create.

Thanks

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

Re: Changing text based on a field value

Post by JohnW »

It seems it does not like the IN statement, and does not handle a 'list of item'.

Is there a workaround for this, other than listing each of the individual IIF statements?
JohnW
Posts: 103
Joined: Mon Nov 20, 2017 8:29 pm

Re: Changing text based on a field value

Post by JohnW »

It also appears you can only run a single IIF, once it returns a true or false value it exits the expression. It does not go to the next IIF statement.
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 try to 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.
Post Reply