IIf is not working with IsNull

I'm trying to make this expression work (in a textbox) with no success:

[IIf(IsNull(fieldA), fieldB, fieldA)]


I set fieldA = null and I expect that fieldB is printed, according to the expression, but fieldA is what is being printed.

Can you help me ?

Comments

  • edited February 2020

    The problem was reproduced. I will inform programmers about it. As a workaround, you can create your own function and use it.

    In the script:

    bool MyIsNull(object n)

      {

       if (n == null)

        return true;

       else

        return false;

      }


    In the designer:

    [IIf(MyIsNull([fieldA]), [fieldB], [fieldA])]

  • Thank you, Anatoly. It works.

  • Amazed years later this still has not been fixed!

    The suggested workaround could be simplified to:

    bool MyIsNull(object n)

       {

         return n == null;

       }

    If the C# script version were updated to newer, it could even just be:

    bool MyIsNull(object n) => n == null;

  • Where do you put the script in please? I am new to FastReports.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.