Page 1 of 1

Variables with multiple conditions

Posted: Tue Apr 01, 2014 12:10 pm
by sbd_jeff
Hi Stimulsoft.
We've been implementing StiReports for the last month, and I've run into an issue that I have not found a technique for doing using Stimulsoft.

In Crystal, we could declare a variable ex. (@SomeName), and we could assign a value to that variable based on an infinite number of nested conditions. For example, if I have two database fields for a product name (ex. Products.Name and Products.VendorProductName) I could tell the Crystal variable to show "VendorProductName" if it is not null over "Name" like so:

Code: Select all

if not isnull({Products.VendorProductName})
then Products.VendorProductName
else {Products.Name}
In Stimulsoft, to achieve the same result, I have to use a ternary operator in an expression.

Code: Select all

!string.IsNullOrEmpty(Products.VendorProductName) ?  Products.VendorProductName : Products.Name
My users will not be able to do ternary statements.
My question is, is there a way to do more than one condition in a variable or other data structure within Stimulsoft where I can do something like:

Code: Select all

if(string.IsNullOrEmpty(Field1))
{
   if(string.IsNullOrEmpty(FIeld2)
   Field3;
   else
   Field2;
}
else
Field1;
Thanks!

Re: Variables with multiple conditions

Posted: Tue Apr 01, 2014 1:01 pm
by Alex K.
Hello,

Please try to use the Switch function for this task.
Switch (condition1, value1, condition2, value2, ...)

Thank you.

Re: Variables with multiple conditions

Posted: Tue Apr 01, 2014 9:12 pm
by sbd_jeff
That works perfectly. Slowly but surely getting it.

Thanks!

Re: Variables with multiple conditions

Posted: Wed Apr 02, 2014 5:04 am
by HighAley
Hello.

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

Thank you.