Skip steps in autonumbered rows - XPath question - InfoPath Dev
in

InfoPath Dev

Skip steps in autonumbered rows - XPath question

Last post 12-18-2012 11:07 PM by Jimmy. 18 replies.
Page 1 of 2 (19 items) 1 2 Next >
Sort Posts: Previous Next
  • 12-17-2012 05:17 PM

    Skip steps in autonumbered rows - XPath question

    I have strange use case where I have repeating rows that are numbered. The users want to delete the number of a row and the row number will remain blank. The subsequent rows will take up the numbering.

    I have this working great with the following code:

    xdMath:Max(../preceding-sibling::my:Step/my:Op-seq) + 1

    (where "Step" is the group and "Op-seq" is the actual step number)

    However, when we insert a step above a blank entry, it renumbers all the blank entries. So the next step was to put a conditional formula in that checks a box to see if the field should remain blank. This is code from MS:

    concat(
    
    substring(string(xdMath:Max(../preceding-sibling::my:Step/my:Op-seq) + 1), 1, (/my:SFields/my:Steps/my:Step/my:HeaderRow!='TRUE') * string-length(string(xdMath:Max(../preceding-sibling::my:Step/my:Op-seq) + 1))),
    
    substring("", 1, (/my:SFields/my:Steps/my:Step/my:HeaderRow!='TRUE') * string-length("")))

    In this case HeaderRow is the boolean that says if the header row should remain blank. But it still doesn't work. I'm not sure what the issue could possibly be. Any tips?

    Filed under: ,
  • 12-17-2012 09:01 PM In reply to

    Re: Skip steps in autonumbered rows - XPath question

    What is the logic you are using to set HeaderRow to true?  Typically a "true" value in XML would be lowercase and not uppercase. 

    Assuming a value of "true" for HeaderRow to indicate it is blank, I think this formula should work:

    substring(count(../preceding-sibling::my:Step[my:HeaderField != "true"]/my:Op-seq) + 1, 1, 5 * ../my:HeaderField != "true")

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 12-17-2012 09:25 PM In reply to

    Re: Skip steps in autonumbered rows - XPath question

    Thank you, Jimmy! The value for TRUE is set by an InfoPath checkbox. I set its values to TRUE for checked and FALSE for not checked. Of course, I can set these for any value. Unfortunately, the formula above populates all the fields with "1" and when I add a step above, repopulates all the blanks with 1, whether the HeaderRow is checked or not. I'm afraid I'm not very good at XPath, so it's all a mystery to me. For all I can tell, the formula I posted above SHOULD work. And I don't know how to debug it effectively.
    Filed under: ,
  • 12-17-2012 09:55 PM In reply to

    Re: Skip steps in autonumbered rows - XPath question

    One thing to note is that if you're using a boolean field, InfoPath will present you with the options of TRUE, FALSE, 1, and 0 when you select default values or set up conditions, but the actual values are true, false, 1, and 0.  It's a little misleading.  So I suspect that even though you've selected TRUE for the checked value, it's probably actually true.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 12-18-2012 06:19 AM In reply to

    Re: Skip steps in autonumbered rows - XPath question

    Thanks! I have changed it to lower-case "true," but I'm still seeing the incorrect behavior. It's not numbering. (every row is "1") and it's still overwriting when I re-order the steps.
  • 12-18-2012 06:48 AM In reply to

    Re: Skip steps in autonumbered rows - XPath question

    Have you tried my formula yet? If you have and it didn't work, would you be able to post your form template here?
    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 12-18-2012 08:08 AM In reply to

    Re: Skip steps in autonumbered rows - XPath question

    I'm not sure I can post the actual form, so I have made a copy of the section in question and applied the formula. It works in this form exactly as it works in my form. In other words, it inserts a "1" into every field regardless, and it allows for the blank spaces to be overwritten when you add a row above. I am so grateful for your help!
  • 12-18-2012 08:51 AM In reply to

    Re: Skip steps in autonumbered rows - XPath question

    If you expand the XPath for the formula, you'll see that you have ../my:HeaderRow inside the square brackets, but it should just be my:HeaderRow there.  That will fix the issue where all the values are 1.

    There was also a mistake in my formula. It should be this:

    substring(count(../preceding-sibling::my:Step[my:HeaderField != "true"]/my:Op-seq) + 1, 1, 5 * (../my:HeaderField != "true"))

    with the added parentheses around ../my:HeaderField != "true"

    As a side note, there isn't a need to put each of the controls into its own repeating section.  You can just place the controls directly into the repeating table and that should work.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 12-18-2012 09:09 AM In reply to

    Re: Skip steps in autonumbered rows - XPath question

    Thank you so much. I do not have them repeating in the actual form, but in the test form I sent you.

    I'm linking to a video that shows the behavior of the formula you specified. There are a couple of variances:

    1.) It does not renumber correclty after the blank space. (e.g. 1, 2, 3, (BLANK), 4, 5 (BLANK), 6)
    2.) It still renumbers blank spaces when a step is inserted anywhere before the blank spaces.

    Form_Autonumber_Misbehavior

    I'm also linking to a video that shows the correct behavior of the renumbering. It would be perfect, but it does not retain the blank spaces after the user inserts a row before. This is in an older version that doesn't have the "HeaderRow" checkbox. This is the problem. I can get it to number perfectly, until the user inserts a row before, then everything blows up, regardless.


    Form_Correct_Behavior_-_without_insert_above
  • 12-18-2012 09:21 AM In reply to

    Re: Skip steps in autonumbered rows - XPath question

    Thank you for going to the trouble of uploading those videos.  I do have the functionality working in your sample form and am attaching it here.

    Could you post the formula you have in its current form? (make sure to check Edit XPath first)

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 12-18-2012 09:27 AM In reply to

    Re: Skip steps in autonumbered rows - XPath question

    Going to the trouble? Are you kidding me? You are helping me out BIG TIME here. I'm going to send you a present.

    Here's the code I have attached to the Op-seq field:
    substring(count(../preceding-sibling::my:Step[my:HeaderRow != "true"]/my:Op-seq) + 1, 1, 5 * (../my:HeaderRow != "true"))
    I'll take a look at the example form now. THANK YOU.
  • 12-18-2012 09:31 AM In reply to

    Re: Skip steps in autonumbered rows - XPath question

    OK - it works perfectly in your example form. EXCELLENT. THANK YOU!! Unfortunately, it's still broken in the actual form. I'm afraid I shouldn't post the actual form here, so I will try to puzzle out the difference, like a monkey with a phaser. -d
  • 12-18-2012 10:02 AM In reply to

    Re: Skip steps in autonumbered rows - XPath question

    All right, one difference in the example form and in my form is the XPath location of Op-seq. (I used "Copy XPath" for both)

    My Form Field Op-seq XPath

    /my:myFields/my:Steps/my:Step/my:Op-seq

    Example Field Op-seq Xpath:

    /my:myFields/my:Step/my:Op-seq
    Should this affect the XPath rule? I don't know enough about the syntax to tell what is root and what is relative.
  • 12-18-2012 10:38 AM In reply to

    Re: Skip steps in autonumbered rows - XPath question

    In your form, is my:Steps the repeating group or is my:Step repeating (or both)?  Could you post a screenshot of your data source taskpane with that part expanded?
    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 12-18-2012 11:16 AM In reply to

    Re: Skip steps in autonumbered rows - XPath question

     

    Jimmy,

    I'm replying for Dan who had to step away for a minute.  Let me know if this is not what you were looking for:

    XXXXXXXXXXXXXXXXXXX I've been trying and cannot find a way to post the screenshot.  Still trying...
Page 1 of 2 (19 items) 1 2 Next >
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.