none
default value via XPath "If Field B is blank" RRS feed

  • Question

  • I've read a lot of posts that come close to this problem, but can't break through it. I have an infoPath form with a field whose default value is set by the following XPath expression

    concat(../my:SITE, " ", substring-before(../my:DATE, "T"))

    I would like to make this conditional on there being a value in a different field (Field B). I have tried:

    (concat(../my:SITE, " ", substring-before(../my:DATE, "T")) | noValue) [(Field B = null) + 1]

    and tried using "is null". If Field B is empty I want no action.

    Can someone straighten me out on this syntax?

    Thanks


    GreenCapitalist

    Thursday, December 12, 2019 7:44 PM

Answers

  • Hi,

    Please note that the conditional default value formula should be formatted as following:

    (TrueResult | ElseResult)[(BoolCondition) + 1]

    If you use this formula to set the default value, the formula will not allow “No action” but give either “TrueResult” or “ElseResult” to the filed.

    If you want to set the field empty when Field B is blank, use the formula below:

    (Field B | concat(../my:SITE," ", substring-before(../my:DATE, "T"))) [(Field B ="") + 1]

    If you want “No Action” when Field B is blank, I suggest you set the default value via Manage Rules > New > Action. Then set the condition as “Field B is not blank” and put the XPath formula under actions.

    Here's your reference.

    Conditional Default Values.

    https://blogs.msdn.microsoft.com/infopath/2006/11/27/conditional-default-values/

    Complex Condition Expressions in InfoPath.

    Please note: Microsoft provides third-party contact information to help you find technical support. This contact information may change without notice. Microsoft does not guarantee the accuracy of this third-party contact information.

    Best regards,

    Chelsea Wu


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Friday, December 13, 2019 7:11 AM