InfoPath 2003 - need help on searching a textbox and to return results in dropdownlist (repeating table scenario) - InfoPath Dev
in

InfoPath Dev

InfoPath 2003 - need help on searching a textbox and to return results in dropdownlist (repeating table scenario)

Last post 09-20-2011 11:33 PM by Patrick Halstead. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 09-20-2011 09:19 PM

    InfoPath 2003 - need help on searching a textbox and to return results in dropdownlist (repeating table scenario)

    Hi,

    I'm an InfoPath newbie, and I'm having problems on how to handle search, please help me out.

    Initially, I have a textbox OnAfterChange event to handle logic:

    function msoxd_my_PersonResponsibleAux::OnAfterChange(eventObj) {

    var ADerror = "Unable to get Enterprise IDs from the server. Connection to the server may not be possible.";

    if (eventObj.IsUndoRedo) { // An undo or redo operation has occurred and the DOM is read-only. return; }

    // A field change has occurred and the DOM is writable. Write code here to respond to the changes.

    try { if (IsUserOnline()) {

    updatePeople(eventObj.Site.text);

    XDocument.View.ForceUpdate(); }

    }

    catch (e) {

    XDocument.UI.Alert(ADerror); return; }

     }

     

    function updatePeople(fieldValue) {

    //Get a reference to the SDS bound to the Web Service.

    var theDataObject = XDocument.DataObjects.Item("PeoplePicker");

    //Set the SelectionNamespaces so that you can find the correct field.

    theDataObject.DOM.setProperty("SelectionNamespaces", 'xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" ' + 'xmlns:s0="http://tempuri.org/"');

    var queryValue = theDataObject.DOM.selectSingleNode( "/dfs:myFields/dfs:queryFields/s0:GetEnterpriseIDsCompletionList/s0:prefixText" );

    queryValue.text = fieldValue;

    queryValue = theDataObject.DOM.selectSingleNode( "/dfs:myFields/dfs:queryFields/s0:GetEnterpriseIDsCompletionList/s0:count" );

    queryValue.text = 20;

     theDataObject.Query();

     }

     

    Both codes are working, but has to lose focus on the textbox first to fill the dropdownlist for the result,

    I'd like to introduce a new approach trough providing a Search button, and to eliminate OnAfterChange event of the textbox:

    function ::OnClick(eventObj){

    var ADerror = "Unable to get Enterprise IDs from the server. Connection to the server may not be possible.";

    if (eventObj.IsUndoRedo) { // An undo or redo operation has occurred and the DOM is read-only. return; }

    // A field change has occurred and the DOM is writable. Write code here to respond to the changes.

    try { if (IsUserOnline()) {

    updatePeople(XDocument.DOM.selectSingleNode("/my:QADeliverySurvey/my:ActionItems/my:ActionItem/my:PersonResponsibleAux").text);

    XDocument.View.ForceUpdate(); }

    }

    catch (e) {

    XDocument.UI.Alert(ADerror); return; }

     }

     Since controls are in a repeating table, whenever I have 2 tables and I do search on the 2nd table, dropdownlist of the first table is also affected by the update which should not be :(

    I don't know how to figure this out, please help me :( Or better if you can provide a better resolution..

     Thanks a lot..

  • 09-20-2011 11:33 PM In reply to

    Re: InfoPath 2003 - need help on searching a textbox and to return results in dropdownlist (repeating table scenario)

    Why are you searching a text box? That's a lot of work and requires code and that code won't work in the InfoPath 2007 browser object model (nor InfoPath 2010 for that matter).

    Instead, why not just change your secondary data source to get the list of people in a repeating XML structure. Then, you can just copy the person from the list into your main data source. That's the easy approach. No need to write code here.

    Patrick Halstead
    Project Manager at Qdabra
Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.