Conditional Default using xPath ("or" in a boolean) - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Conditional Default using xPath ("or" in a boolean)

Last post 02-10-2020 05:50 AM by granDelimiter. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 02-07-2020 07:57 AM

    Conditional Default using xPath ("or" in a boolean)

    In infoPath I have for the default of a field; xpath for If me - "string1" else - "string 2". Here it is: concat(substring("Supervisor", 1, (../my:preferredName = "myName") * string-length("Supervisor")), substring("Technician", 1, (not(../my:preferredName = "myName")) * string-length("Technician"))). I want to cover all the supervisors, so "myName" or "hisName" or "herName". When I try just using "or" and adding names like that it stops working. It gets put in without error messages but it spits out "Supervisor" even if I misspell all the names. Any way to get an "or" statement into a boolean in xpath? Thanks p.s. I think I have a work-around using a sharePoint calculated column to get a default value (sharepoint calculations are easier), but it seem resource-heavy (a whole extra column, recalculated every log on). p.p.s This work-around is not working either.
  • 02-07-2020 03:42 PM In reply to

    Re: Conditional Default using xPath ("or" in a boolean)

    I would probably get all of this outside of the form / list and into its own list. Like - a list that has two columns, one for "Role" (string or choice) and one for "Person" (person or group). You'd have entries like:

    Role Person
    Supervisor Jane Doe
    Technician John Smith
    Technician Sue Jones
    Supervisor Bob Roe

    Then, in your form, instead of having to do this kind of conditional logic, you could simply compare to the Role in the list. I'm not quite sure I understand how you are using this default - but if you can take a more data-driven approach, you won't have to deal with this sort of work-around.

    Hilary Stoupa

  • 02-08-2020 02:51 PM In reply to

    Re: Conditional Default using xPath ("or" in a boolean)

    Thanks, I see how an outside list with all personnel and their roles would work. However I don't have a list of all technicians. I only know who the supervisors are. So I still need a function for "IF( A or B or C..)" or "IF(A in (B,C,D))". The rules in infopath could use something like that to change a field, but not to set its default. For our purposes, for now at least, its probably prudent to just require users to enter their position.
  • 02-08-2020 04:34 PM In reply to

    Re: Conditional Default using xPath ("or" in a boolean)

    OK, here's what will work: Set the field's value in infoPath rules (which allow "If a and If b ..." etc), but have one of the conditions be "if the field is blank". That is the equivalent of setting a default for the field. I never would have thought of it without your help. gran
    Filed under:
  • 02-10-2020 05:50 AM In reply to

    Re: Conditional Default using xPath ("or" in a boolean)

    slight modification needed: A form load rule sets the value to 'supervisor' if preferredName is SupervisorA or SupervisorB or SupervisorC, and otherwise the control's default value sets it to 'technician'. In retrospect, I may go back to manual entry just for stability and simplicity given the minimal extra convenience automation gave
Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.