Current Item in repeating group - InfoPath Dev
in

InfoPath Dev

Current Item in repeating group

Last post 11-27-2006 04:52 PM by Greg Collins. 13 replies.
Page 1 of 1 (14 items)
Sort Posts: Previous Next
  • 10-30-2006 01:35 AM

    • spudy
    • Top 150 Contributor
    • Joined on 03-23-2006
    • United Kingdom
    • Posts 67

    Current Item in repeating group

    I am looking to get the value of the current field in a master/detail repeating table from a different section of the form.

    Can anyone help?

    thanks SPudy
  • 10-31-2006 11:55 PM In reply to

    • Shiva
    • Top 25 Contributor
    • Joined on 04-15-2005
    • India
    • Posts 694

    Re: Current Item in repeating group

    Hi Spudy,

    Can you check out this link get the more information,
    http://www.infopathdev.com/forums/topic.asp?TOPIC_ID=47
  • 11-15-2006 09:49 AM In reply to

    • spudy
    • Top 150 Contributor
    • Joined on 03-23-2006
    • United Kingdom
    • Posts 67

    Re: Current Item in repeating group

    I tried that post, it has reference to the current() expression but I cannot get that working for me.

    I have two master/detail controls. 'Employee' records personal information about staff. 'Hours' records information about the hours worked by the staff member selected in 'Employee'.

    When the selection in 'Employee' has changed I need to capture the UID for the staff member so it can be used firstly to filter the 'Hours' master/detail control and then also as a key reference identifier if a new row is inserted into the 'Hours' master/detail control.

    Spudy
  • 11-15-2006 04:42 PM In reply to

    Re: Current Item in repeating group

    Perhaps what you are looking for is the OnContextChange event.
  • 11-16-2006 05:07 AM In reply to

    • spudy
    • Top 150 Contributor
    • Joined on 03-23-2006
    • United Kingdom
    • Posts 67

    Re: Current Item in repeating group

    Greg,

    I have a uid in field EmployeeID with parent node of Employee which is the master table. On selecting insert on the Hours master table I presume the oncontextchange event will be fired. In this code I am simply trying to place it in a node called CurrentEmployeeID - but it does not work.

    Here is the code for the oncontextchange:

    function XDocument::OnContextChange(eventObj)
    {
    var oContextNode = eventObj.Context;
    if (eventObj.Type == "ContextNode")
    {
    if (oContextNode.nodeName == "//my:Employee" )
    XDocument.DOM.selectSingleNode("//my:CurrentEmployeeID").nodeTypedValue = XDocument.DOM.selectSingleNode("//my:EmployeeID").nodeTypedValue ;
    return;
    }
    }


    thanks Spudy
  • 11-16-2006 09:18 AM In reply to

    Re: Current Item in repeating group

    nodeName will never have slashes in it. You should check for .nodeName == "my:Employee".
  • 11-17-2006 09:04 AM In reply to

    • spudy
    • Top 150 Contributor
    • Joined on 03-23-2006
    • United Kingdom
    • Posts 67

    Re: Current Item in repeating group

    Greg,

    I have tried without the slashes but it is still not working. I ventured further and a search of the website revealed one of your "how to" tutorials:

    http://www.infopathdev.com/howto/tutorials/default.aspx?i=554349415b544aa18f2dff9a864bc9af

    I suspect that this could be shaped somehow to resolve my problem.
    Could you advise how I can set the value of a global variable to the acive fields actual value through using the oncontextchange event?

    Thanks Spudy.
  • 11-17-2006 09:54 AM In reply to

    Re: Current Item in repeating group

    Hold on. Let's backtrack here. There's probably an easier way to do what you are doing built right into the master/detail control.

    On the open the properties dialog for the detail section.
    On the Master/Detail tab, you'll probably find that you have the relationship using the "position".
    Change this relationship to use a "key field". Set the key field in both the master and detail to the the Employee node (or a more suitable node).
    Be sure the check box is selected to copy the key field from the master when a new detail is inserted.

    See if this gives you what you need.
  • 11-17-2006 11:02 AM In reply to

    • spudy
    • Top 150 Contributor
    • Joined on 03-23-2006
    • United Kingdom
    • Posts 67

    Re: Current Item in repeating group

    Greg, Sorry I probably haven't conveyed very well what it is I need to do, and I appreciate your help with this.

    I have a master/detail control which has a key field as a unique identifier.
    There is then another master/detail control (pointing to a different repeating group) that stores the hours worked by individual employees and details about how those hours were spent.

    When an employee is selected in the first master/detail control, I want to capture the UID for the current row.

    Then when a new row is inserted in the other master/detail for hours, I can provide the UID for the employee added in order that I can cross reference the hours back to the employees.

    Thanks Spudy
  • 11-17-2006 12:40 PM In reply to

    • spudy
    • Top 150 Contributor
    • Joined on 03-23-2006
    • United Kingdom
    • Posts 67

    Re: Current Item in repeating group

    Having looked at another of your "how to" Select a Master Table Row via Code I got some more interesting pointers.

    Using the expression :
    xdXDocument:GetNamedNodeProperty(my:Members, "CTRL1_5", 1)

    You were able to display the position of the currently selected row in the master data table.
    I have found the control id for my table and replaced my:Members with my own group.
    I tried the same but without success. What happens is that the expression always displays 1.
    I am now thinking that if I can retrieve the position number in this way, when I insert a new row in my other master/detail table I can use the position reference to track down my UID.

    It just feels like I am running about barking at all the trees in the wood now!
  • 11-20-2006 09:55 AM In reply to

    Re: Current Item in repeating group

    Yes, once you have the position of the row, you can use that position in a filter (i.e. Table/Row[Number]/FieldOfInterest).

    You are getting 1 back because somehow you are not connecting to the master table properly with your XPath, and you've specified 1 as teh default return value. When you look in your view .xsl file, you will find existing GetNamedNodeProperty methods for your master/detail controls. These existing methods can help you identify the correct XPath to get the row number you need.
  • 11-22-2006 03:33 AM In reply to

    • spudy
    • Top 150 Contributor
    • Joined on 03-23-2006
    • United Kingdom
    • Posts 67

    Re: Current Item in repeating group

    I have the expression working fine now. Now I am trying to get that
    value stored in some way that I can call on it elsewhere for
    filtering and to insert a value from the row into another mster/detail table when a new row is inserted.

    How can I store and reuse that row number as part of a filter and in
    a rule?

    I presume the way to do this would be to store the value as a global
    variable through the oncontextchange event which I tried this but without success.

    Thanks Spudy
  • 11-22-2006 03:18 PM In reply to

    • spudy
    • Top 150 Contributor
    • Joined on 03-23-2006
    • United Kingdom
    • Posts 67

    Re: Current Item in repeating group

    I have tried the following expression within a rule on inserting a
    new row in the master/detail table called 'hours'. I am trying to get
    the value of UID from the other master/detail table called Employee.

    The problem is that the default value (1)of the getnamednodeproperty
    is being used. I have checked that the CTRLID is correct.

    //my:EmployeeSection/my:Employee[(position() = xdXDocument:GetNamedNodeProperty
    (../../my:External/my:EmployeeSection, "CTRL48_35",
    1))]/my:EmployeeID


    Any ideas?

    Thanks Spudy
  • 11-27-2006 04:52 PM In reply to

    Re: Current Item in repeating group

    Is my:EmployeeSection a repeating node? If so, that's probably your troubles, as the value would be stored on a specific repeating node. Try having SetNamedNodeProperty store the value on the root node of your schema instead.
Page 1 of 1 (14 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.