Default IF - InfoPath Dev
in

InfoPath Dev

Default IF

Last post 06-26-2006 09:35 PM by SamDahl. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 06-20-2006 06:35 PM

    • SamDahl
    • Top 500 Contributor
    • Joined on 03-28-2006
    • Australia
    • Posts 44

    Default IF

    Hi,

    I have a text fieldA and it's value is set by a formula using the Default Value option.
    Is there a way to only use this default if fieldB has a value of 'x'?
    Or do I have to go and write code?

    TIA
  • 06-20-2006 07:02 PM In reply to

    Hi Sam,

    You should be able to do this with Rules instead of code. Double-click FieldB, click Rules, click Add, and then click Edit Condition. Set the drop-downs to "FieldB" "is equal to" 'x'. Click Ok. Now click Add Action and select "Set Fields Value" from the drop-down list. Select FieldA in the first box, and then input the default value formula into the second box.

    I hope this helps, let us know how it goes!
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 06-20-2006 07:08 PM In reply to

    Hello

    You can do this using Conditional Formatting. Try these steps

    1) Insert Two Text Boxes A and B and a third text box C
    2) In the Text Box A insert your default Formula and put conditional formatting to hide this Text Box A if C is not equal to X
    3) In the text Box B Don#%92t insert any default formula and put conditional formatting to hide this text box B if C is equal to X

    Result: You will see that if X is entered in C then Text box A with default Formula is shown and if it is not then text Box B is shown.

    I hope this helps you.
    Kalyan G Reddy
    Infopath MVP 2007 and 2008
  • 06-20-2006 10:08 PM In reply to

    • SamDahl
    • Top 500 Contributor
    • Joined on 03-28-2006
    • Australia
    • Posts 44
    Thanks Matt, it's been a while since I messed with this stuff but it's funny how it all makes sense when someone tells you the answer. Works a charm, but...

    Alas, the situation is more complex than I had thought...

    fieldA contains serial numbers for a device and gets it's value (by means of a Default Value, as said previously) from a secondary datasource. So when the 2DS changes the field should update.
    FieldB is a DDL of the device types. Only ceartain device types have their serial number available in the fieldA 2DS. FieldB has other rules on it that make reselecting the device type arbitrarily (to trigger a rule to update serial numbers) very bad.

    The problem with the current (Default Value) situation is that, for devices that do not have a serial number in the 2DS, the Serial number will default to blank when the form is opened. So where a serial number is not in 2DS and you enter it manually, then reopen the form... it's gone again.

    Having re-examined this situation it seems to me I'll have to look at filling this field with code in the OnLoad event.

    Any further thoughts/ fully worked solutions? ;-) hehe
  • 06-26-2006 09:35 PM In reply to

    • SamDahl
    • Top 500 Contributor
    • Joined on 03-28-2006
    • Australia
    • Posts 44
    This is the formula I use to get pull in the default value:
    xdXDocument:GetDOM("serial_numbers")/dfs:myFields/dfs:dataFields/d:serials/@value[../@host_name = contains(../@host_name, translate(xdXDocument:get-DOM()/my:myFields/my:group4/my:deviceName, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz"))]

    How does one go about converting such a formula to code? (I'm using JScript)
Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.