Distinguish between new & existing rows? - InfoPath Dev
in

InfoPath Dev

Distinguish between new & existing rows?

Last post 11-18-2004 10:50 AM by Greg Collins. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 11-12-2004 04:49 AM

    • jonbrave
    • Top 200 Contributor
    • Joined on 10-15-2004
    • United Kingdom
    • Posts 59

    Distinguish between new & existing rows?

    Can it be done?

    I have a repeating section tied to a table. I populate in preparation for submit. What I want is that (previously) existing rows should be non-editable/read-only, but the user can insert new rows.

    I disable "Remove" to prevent user deleting existing ones; fine (actually, unfortunately he then can't change his mind and delete a new row he adds, but I can see that's a difficult one).

    But now I can't win: if I mark the fields readonly my added row gets readonly; so I don't, and that means existing row fields are editable :(

    Is there anything I can test in a rule/condition to see if I'm on an added row (to use that for field editability disablement)?

    I can think of adding a dummy boolean column that I set via a rule on section insert, but unfortunately I don't have the luxury of adding this (conveniently) into my schema (generated from WS/DataSet)...
  • 11-12-2004 10:50 AM In reply to

    Re: Distinguish between new & existing rows?

    It's not that difficult of a problem, but will require the addition of a flag attribute on your row. Here's what I have in mind:

    You could add a boolean attribute to the repeating rode representing the row. Say the attribute is @new and the default value is true.

    When new rows are inserted, the value of @new is true. This is your indicator to show editable fields.

    On save, set all those @new values to false. Then when the form is reopened, all the values are false and the rows show expression boxes instead.

    @new on newly inserted rows will always be true, and saved rows will always be false.

    Greg Collins [InfoPath MVP]
  • 11-15-2004 09:58 AM In reply to

    • jonbrave
    • Top 200 Contributor
    • Joined on 10-15-2004
    • United Kingdom
    • Posts 59

    Re: Distinguish between new & existing rows?

    But, Greg, I don't see how I could do this?

    I said:
    quote:
    I can think of adding a dummy boolean column that I set via a rule on section insert, but unfortunately I don't have the luxury of adding this (conveniently) into my schema (generated from WS/DataSet)...



    You talk about:
    quote:
    You could add a boolean attribute to the repeating rode representing the row

    Unless attributes are handled any differently from an extra column, how can I do this? Remember, when IP gets schema from DataSet everything inside, say, "dataFields" is readonly and you cannot "Add" any variables/attributes... The only place one can Add variables is into the root node "/myFields", and I don't see how that would get me anywhere....
  • 11-15-2004 10:40 AM In reply to

    Re: Distinguish between new & existing rows?

    Sorry, I must have missed that last paragraph on your original post.

    One option you have is to create a secondary DOM based off the schema of your data set with the addition of the boolean. Copy the data into the secondary DOM and set the boolean to true. Use the secondary DOM in the view. All new rows will automatically have false for the boolean. Then copy it back to the data set for save/submit.

    Greg Collins [InfoPath MVP]
  • 11-16-2004 03:34 AM In reply to

    • jonbrave
    • Top 200 Contributor
    • Joined on 10-15-2004
    • United Kingdom
    • Posts 59

    Re: Distinguish between new & existing rows?

    Hmmmm....

    And where's the other option so I can just test whether a row is new or not without all of this? :)
  • 11-18-2004 10:50 AM In reply to

    Re: Distinguish between new & existing rows?

    The problem is you don't have control over the schema. There is no way of knowing whether a row is new unless you have some kind of a flag.

    It seems your only option at this point is to create a copy with the flag, use the copy for your editing, then post back without the flag when you save.

    Unless you can modify the main schema, I don't see another choice.

    Greg Collins [InfoPath MVP]
Page 1 of 1 (6 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.