Dropdownlist display name in a repeating table - InfoPath Dev
in

InfoPath Dev

Dropdownlist display name in a repeating table

Last post 05-24-2006 01:43 PM by skydolphin. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 05-24-2006 11:44 AM

    Dropdownlist display name in a repeating table

    Hi everyone,

    I have been pulling my hair out about this for 2 weeks now and I'm getting nowhere. I hope someone can help.

    I have a repeating table that has a dropdownlist in it. When the user selects an item in the list, I want to populate two other fields. One with the value (which is working fine) and the other with the display name. I need these values to post to a SQL table on submit. I wrote some code in the onchangeafter event that works for the first dropdown only. If the user adds another row it doesn't work for that row. Below is my code. I kind of understand why it isn't working (no index for the specific control) but I don't know how to make it work.

    var strNewValue = XDocument.DOM.selectSingleNode("/my:ExpenseClaim/my:ExpenseItems/my:CategoryName").text;
    var sCo = XDocument.DOM.selectSingleNode("/my:ExpenseClaim/my:EmployeeDetails/my:Company").text;
    var sDept = XDocument.DOM.selectSingleNode("/my:ExpenseClaim/my:EmployeeDetails/my:Department").text;

    var theDataObject = XDocument.DataObjects["GetCategories"];

    theDataObject.DOM.selectSingleNode("//*[local-name()='Company']").text = sCo;
    theDataObject.DOM.selectSingleNode("//*[local-name()='Department']").text = sDept;
    theDataObject.Query();

    var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
    xmlDoc.async = false;
    xmlDoc.loadXML(theDataObject.DOM.xml);

    var root = xmlDoc.getElementsByTagName("*");
    var acctCode, accName;
    for (var i=0; i<= (root.length - 1); i++)
    {
    if (root.item(i).nodeName == "AccountCode")
    {
    acctCode = root.item(i).text;
    if (acctCode == strNewValue)
    {
    acctName = root.item(i+1).text;
    }

    }
    }

    I don't know what to do to make this work. I thought if I could add the code to a rule that might help but I don't know how to do that.

    Since I am totally lost, very specific answers would be most helpful as all I am finding are generic "You need add code to the function on the datasource default value" answers. Makes sense, but I don't how to do that or what the code should look like.

    Thanks for your patience and help.

    Rhonda
    [email protected]
  • 05-24-2006 12:55 PM In reply to

    Re: Dropdownlist display name in a repeating table

    Hi Rhonda,

    I get the feeling that you are making this way too complicated that it should be. I know you wanted specific answers, but have you seen this HowTo?http://www.infopathdev.com/howto/tutorials/default.aspx?i=9111ef580f95479890fc18fb2c5bac85

    If that doesn't help I will try to help you debug your code, but it looks pretty complicated for such a normal task.

    I hope this helps, and stop pulling out your hair!
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 05-24-2006 01:31 PM In reply to

    Re: Dropdownlist display name in a repeating table

    Thanks Matt,

    I think I am getting closer. Here is what I have now and the error message I am getting.

    <?xml version="1.0" encoding="utf-8" ?>
    - <NewDataSet>
    - <Table>
    - <SAPCodes>
    <AccountCode>_SYS00000000679</AccountCode>
    <AccountName>Airfare</AccountName>
    <SegmentCode>61110</SegmentCode>
    </SAPCodes>
    - </Table>
    </NewDataSet>

    xdXDocument:GetDOM("GetCategories")/NewDataSet/Table/SAPCodes/AccountName[../AccountCode = current()]

    "xdXDocument:GetDOM("GetCategories")/NewDataSet/Table/SAPCodes/AccountCode" does not point to a valid location path of a field or group.


    Thanks,

    Rhonda
  • 05-24-2006 01:43 PM In reply to

    Re: Dropdownlist display name in a repeating table

    OH I got it! It ended up looking more like this in the end.

    xdXDocument:GetDOM("GetCategories")/dfs:myFields/dfs:dataFields/ns2:GetCategoriesResponse/ns2:GetCategoriesResult/NewDataSet/Table/SAPCodes/AccountName[../AccountCode = current()]

    Thanks for you help. That was the little piece that was missing. Now I can go home for the day since I accomplished something. Oh if only...

    Rhonda
Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.