Simple Syntax Problem for Position()...I Hope! - InfoPath Dev
in

InfoPath Dev

Simple Syntax Problem for Position()...I Hope!

Last post 03-14-2012 08:36 PM by Jimmy. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 03-14-2012 09:07 AM

    Simple Syntax Problem for Position()...I Hope!

    I'm trying to create a Default Value for a textbox that is in a repeating table.  Since you can't set up an if-then-else structure for Default Value, I did some research and found this article, which in Method 2 references a nasty concat(substring()) thing that I think might do what I need.  Thing is, the condition I need to evaluate as true or false is the row number of my textbox, and I'm having some trouble building the correct syntax.  The function help says that the syntax for position is position(field) and everywhere else in Default Value I can use "." (without quotes) to denote the current field, yet when I put (position(.) < 9) for the true condition on my first substring, it says that position(.) contains an invalid number of arguments.  Hunhhh???  I also tried (.[position() < 9) and got a different error, but I think that the []s indicate filter syntax, which is not what I need here. 

    Better yet, when I try to Google examples of position() syntax, I don't find much.

    Do any of you who know IP and XPath better than this poor clueless newbie know the correct syntax for what I'm trying to do?  If it helps any, the overall string I'm trying to build is concat(substring("Incident", 1, (position(.) < 9) * string-length("Incident")), substring("Change", 1, (position(.) > 8 and position(.) < 12) *string-length("Change")), substring("Problem", 1, (position(.) = 12) * string-length("Problem")), substring("Any", 1, (position(.) = 13) * string-length("Any")))

    Thanks,

    nkstrou

    An imprecisely defined requirement has an infinite number of possible solutions. Unfortunately, only about a maxiumum of 3 solutions are actually satisfactory to the end user.
  • 03-14-2012 12:21 PM In reply to

    Re: Simple Syntax Problem for Position()...I Hope!

    Anson Hidajat
    Qdabra® Software/ InfoPathDev.com
    The InfoPath Experts – Streamline data gathering to turn process into knowledge.™

  • 03-14-2012 08:36 PM In reply to

    Re: Simple Syntax Problem for Position()...I Hope!

    Typically position() is used with no arguments, but I think there's a high likelyhood that it won't be of any help in this situation, no matter how you use it.  Though it will make the formula even uglier, I think Anson's preceding-sibling:: suggestion is probably the way to go.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.