IIF and Substring

Stimulsoft Reports.WEB discussion
Post Reply
JockeD
Posts: 77
Joined: Fri Apr 17, 2009 1:47 pm
Location: Sweden

IIF and Substring

Post by JockeD »

Hello,

I not sure if I miss something obvious here but I have a problem with the following text epression

Code: Select all

{IIF(Length(Events.Comment)>50, Substring(Events.Comment,0,47) + "...", Events.Comment)}
If the expresion is true then the text is ok but nohing is displayed when the expresion is false.
If I remove the Substring everything works as expected.

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

IIF and Substring

Post by Alex K. »

Hello,

In this case, it is due to the fact that the IIF () method is attempting to execute both conditions, and it turns that an exception is thrown due to the length of the string. You can use the following expression for the solution of this problem:

Code: Select all

{Length(Events.Comment)>50 ? Substring(Events.Comment,0,47) + "..." : Events.Comment}
Also, in the nearest future, we plan to extend the functionality that can be used in expressions.


Thank you.
JockeD
Posts: 77
Joined: Fri Apr 17, 2009 1:47 pm
Location: Sweden

IIF and Substring

Post by JockeD »

Thank you, Aleksey

The report is in VB so I changed to

Code: Select all

{IF(Length(Events.Comment) > 50, Events.Comment.Substring(0,47) + "...", Events.Comment)}
Everything works as expected.

Thank you!

/Joakim

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

IIF and Substring

Post by Alex K. »

Hello,

We are always glad to help you!
Let us know if you need any additional help.

Thank you.
Kowal
Posts: 2
Joined: Mon Jun 13, 2016 1:15 pm

Re: IIF and Substring

Post by Kowal »

Hello,

I also have a problem with IIF and Substring. I have build this formula:

Code: Select all

{IIF(Substring(address.address_opendays,0,1) == "N","NotWorking","Working")}
Syntax check is OK, but when i want to make a preview it throwing an error.
Could you tell me where i',m making mistake ?

Many Thanks,
Kowal
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: IIF and Substring

Post by HighAley »

Hello, Kowal.

Could you specify what error do you get?
What version of our report do you use?

Thank you.
Kowal
Posts: 2
Joined: Mon Jun 13, 2016 1:15 pm

Re: IIF and Substring

Post by Kowal »

Add a screen of error in attachment.
I am using this software for the first time. How can i check report version ?

Thank you.
Attachments
error.png
error.png (45.96 KiB) Viewed 8578 times
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: IIF and Substring

Post by HighAley »

Hello.

Maybe the address.address_opendays is NULL or empty?
We need to see your report template with sample data to reproduce the issue.

Thank you.
Post Reply