Passing Values Between Forms - InfoPath Dev
in

InfoPath Dev

Passing Values Between Forms

Last post 03-21-2007 08:26 AM by ssaral. 17 replies.
Page 1 of 2 (18 items) 1 2 Next >
Sort Posts: Previous Next
  • 03-14-2007 09:01 AM

    Passing Values Between Forms

    Hi,

    I have an InfoPath 2003 SP1 form that lists the contents of a table from SQL Server 2000. As an example, the information displayed by this form is as follows:

    ID Value
    1 Red
    2 Blue
    3 Green
    4 Black
    5 Yellow

    The table above is load when the form is opened and the field are displayed as read-only fields. What I would like to do it start a second form from this form to edit a particular line item.

    So for example I would like to display the content on the first form as follows:

    ID Value
    1 Red Edit
    2 Blue Edit
    3 Green Edit
    4 Black Edit
    5 Yellow Edit

    Now when you click on Edit it will start another form with the selected line item already load into the form and let you edit that particular line item. Edit could be a link or a button, but for this scenario to work I will need to pass a line item value between two form which is something I haven't been able to figure out any ideas on how to make this work...thanks


  • 03-14-2007 09:40 AM In reply to

    Re: Passing Values Between Forms

    Please read the following thread. Might be best to start bottom-up rather than top-down. Then download the file I posted there as a sample.
  • 03-14-2007 11:44 AM In reply to

    Re: Passing Values Between Forms

    Where is the thread? Can you include a link for the thread as well...thanks
  • 03-14-2007 01:55 PM In reply to

    Re: Passing Values Between Forms

    Sorry - forgot to add the link. Here it is:

    http://www.infopathdev.com/forums/topic.asp?TOPIC_ID=4451
  • 03-15-2007 05:51 AM In reply to

    Re: Passing Values Between Forms

    Thanks I'll give this method a try
  • 03-15-2007 07:51 AM In reply to

    Re: Passing Values Between Forms

    getting closer...the thing is I'm using a repeating table to display my values and when I use:

    var value = XDocument.DOM.selectSingleNode("/dfs:myFields/dfs:dataFields/d:ProductLinesValu
    e/@ProductLineValue");

    it populates all my Edit buttons with the first value of from the repeating table, so I tried using:

    var value = XDocument.DOM.selectNodes("/dfs:myFields/dfs:dataFields/d:ProductLinesValu
    e/@ProductLineValue");

    which doesn't return any values, is there a different property I need to use for XDocument to get each row item read into it's own button....can I put current() in there somewhere, what is the syntax for that...thanks
  • 03-15-2007 09:50 AM In reply to

    Re: Passing Values Between Forms

    selectNodes() will return a list of nodes... then you must step through them one by one.

    var value;
    var values = XDocument.DOM.selectNodes("/dfs:myFields/dfs:dataFields/d:ProductLinesValu
    e/@ProductLineValue");

    while(value = values.nextNode())
    {
    // do something with value node here...
    }
  • 03-15-2007 01:21 PM In reply to

    Re: Passing Values Between Forms

    Thanks for the response, but I'm really bad with writing scripts...what would that something be?

    I'm trying to assign those node values to a button in each row of a repeating table.

    So the 'var value' would equal to every value in 'var values', but I'm not sure how to write the code for that.........thanks
  • 03-15-2007 02:10 PM In reply to

    Re: Passing Values Between Forms

    values is a collection of all @ProductLineValue attributes (the actual attributes, not just their values).

    value gets set to each item in the values collection, one-by-one, not "every value in values" -- just one value at a time.

    When you say assign to button, what do you mean? Are you talking about a Button Control?

    Also are you using InfoPath 2003 or 2007?

    So are you copying values within the same table, or from one table to another?
  • 03-16-2007 05:39 AM In reply to

    Re: Passing Values Between Forms

    Yes, I mean a button control and I'm using InfoPath 2003 SP1. I believe I don't want to copy values from one table to another.

    The concept I'm trying to implement is as follows:

    ProductLinesValue is a column in a table with lots of stuff in it. I wanted to display each row value in that column, which can easily be done using a repeating table. Next I want to place a button control next to each row item inside the repeating table (in another column) that is set to the value of that row. I will later use this button to open another form that lets you edit that selected row value and submit it back to the db it came from......thanks

    So the end result for example would look like this on the form:

    Red Edit
    Blue Edit
    Green Edit
    Black Edit
    Yellow Edit
  • 03-16-2007 09:30 AM In reply to

    Re: Passing Values Between Forms

    So if you have a single repeating table and want to set the value of another field within the same row, you can use rules for this... Rules work such that when a value changes on a field, the rules for that field get run. This lets you change the value of another field on that same row very easily.

    HOWEVER... you talk about buttons and setting values on buttons. I am not sure exactly what you mean by that. IF you mean that you want to change the button's label (i.e. the visible text on the button) then you will not be able to do this. InfoPath 2003 does not support dynamic button labels, while InfoPath 2007 does. This is why I asked you about which version you are using. If you have some other thing you want to do with the buttons and the values, please explain further.
  • 03-19-2007 11:14 AM In reply to

    Re: Passing Values Between Forms

    I#%92m not trying to change the Label of a button; the label will stay static.

    I would like to use a button to open another form (which is easy to do with rules) but at the same time I would also like to pass some values from a specific row of the repeating table where you clicked the button to open that second form.

    I have it sort of working based on your previously downloaded samples, but the button is only passing the first row item from the repeating table. I would like each button to pass its equivalent row value...thanks
  • 03-19-2007 11:51 AM In reply to

    Re: Passing Values Between Forms

    Ah, okay. So what you need to do is to get the current row of your current table, so that you know which row to update in your second form.

    You can do this using the preceding-sibling:: axis. This would be something like:

    var rowNumber = eventObj.Source.selectNodes("preceding-sibling::my:RowNodeName").length + 1

    Then use rowNumber to set the proper row in the other form using the xpath filter "[]"

    selectSingleNode("/Table/Row[" + rowNumber + "]/Field").text = Value

    Hope this helps.

    - - - - -

    P.S. I would also highly recommend updating to SP2. There were numerous bug fixes in SP2 and it has been proven stable.
  • 03-19-2007 12:24 PM In reply to

    Re: Passing Values Between Forms

    Yes this is very helpful, so I would use it like this then:

    var rowNumber = eventObj.Source.selectNodes("preceding-sibling::dfs:myFields/dfs:dataFields/d:ProductLinesValue/@ProductLineValue").length + 1

    but I don't know how many rows it will end-up selecting...is there a way you can tell it to count through all the rows...?

    Thanks
  • 03-19-2007 02:33 PM In reply to

    Re: Passing Values Between Forms

    No, no. Preceding-sibling doesn't work the way you are trying to use it. It needs to start from your current selection (i.e. eventObj.Source). You're trying to make it go all the way back to the root node, which has NO preceding siblings. And you need to also use it on a Repeating Node (i.e. the table row itself), not an Attribute.

    So it would be more like this:

    var rowNumber = eventObj.Source.selectNodes("preceding-sibling::d:ProductLinesValue").length + 1

    It selects rows ONLY to get the count. That's how you can figure out which row # you were on when you clicked the button. Notice the ".length + 1" This says to get the count of all the rows before the one you clicked the button on, PLUS count in the current row. That gives the accurate row number that you will need for selecting the same row number in the other form.
Page 1 of 2 (18 items) 1 2 Next >
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.