How to use an "if" in an expression box? - InfoPath Dev
in

InfoPath Dev

How to use an "if" in an expression box?

Last post 02-15-2011 06:31 PM by arangas. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 02-15-2011 04:14 PM

    How to use an "if" in an expression box?

    I have a field called PayRateUnformatted containing an integer value. Then there's the field PayRate which contains the following default expression:

    concat(../my:Working/my:PayRateUnformatted, "%")

    This isn't quite right. The field PayRate should contain the value "N/H" if PayRateUnformatted == 0.

    Is there any way to do this?

     

  • 02-15-2011 05:52 PM In reply to

    Re: How to use an "if" in an expression box?

    There is. The formula is a little challenging -- here's a explanation of it.

    But, you know -- do you need to store the "formatted" pay rate? Why not just put two expressions boxes (calculated values in IP 2010) on your form with some conditional formatting. One has the text "N/H" in it, and is conditionally formatted to hide if PayRateUnformatted != 0. The other is PayRateUnformatted formatted as a percent (so you don't have to concat) or your original concat formula. Hide if PayRateUnformatted = 0.

    I suppose, if you are promoting the PayRate to your SharePoint library, you'd need that formatted field though. I think the link in my first paragraph's Method 2 would work for you... something like this:

    concat(
    substring("N/H", 1, (../my:Working/my:PayRateUnformatted = 0) * 3),
    substring(concat(../my:Working/my:PayRateUnformatted, "%") , 1, (not(../my:Working/my:PayRateUnformatted = 0)) * string-length(concat(../my:Working/my:PayRateUnformatted, "%"))))

     

    Hilary Stoupa

  • 02-15-2011 06:31 PM In reply to

    Re: How to use an "if" in an expression box?

    Great post on the InfoPath team blog! Wish I'd been able to find that! You're right, I may be able to use conditional formatting. However this was the simpler of my two examples that I need to use 'if' for. Thanks for your help, much appreciated!
Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.