Problems setting fields based on dropdown - InfoPath Dev
in

InfoPath Dev

Problems setting fields based on dropdown

Last post 02-16-2007 12:57 AM by Patrick Halstead. 10 replies.
Page 1 of 1 (11 items)
Sort Posts: Previous Next
  • 08-12-2005 06:08 PM

    Problems setting fields based on dropdown

    I'm having some major problems trying to do what seems like a simple task: populate fields in the main data source with values from a secondary data source based on the current dropdown menu selection.

    I'm using SP1 and VB.NET.

    I first tried what I thought would be the easiest route: creating a rule set's a field's value when the field associated with the dropdown menu is not blank. In other words, the dropdown menu loads with the first option blank. If the user selects any other option I wanted to use the option's value to filter a set of other values from my secondary data source ("Companies") and display them in expression boxes. Seems really straight forward. But when I preview my form and make a dropdown menu selection I get the exceedingly helpful error message "Some rules were not applied. Unspecified error". There seems to be no valid reason for this.

    Here's an example of the rule's action formula I'm using to set a field's value:

    xdXDocument:GetDOM("Companies")/dfs:myFields/dfs:dataFields/d:Companies/@x86_PCs[../@ID = xdXDocument:get-DOM()/my:myFields/my:NominatedCompany/my:AccessDB_ID]

    So I tried another approach: add code to the dropdown menu's OnAfterChange event handler, such as:

    =========

    Dim dataDOM As DOMDocument50 = thisXDocument.DataObjects("Companies").DOM
    dataDOM.setProperty("SelectionNamespaces", "xmlns:dfs=""http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"" xmlns:d=""http://schemas.microsoft.com/office/infopath/2003/ado/dataFields"" ")

    Dim companyMainDataSourceNode As IXMLDOMNode = thisXDocument.DOM.selectSingleNode("/my:myFields/my:NominatedCompany")

    Dim companySecondaryDataSourceNode As IXMLDOMNode = dataDOM.selectSingleNode("/dfs:myFields/dfs:dataFields/d:Companies[@ID = """ & e.NewValue & """]")

    companyMainDataSourceNode.selectSingleNode("my:_x86PCs").text = companySecondaryDataSourceNode.selectSingleNode("@x86_PCs").text

    =========

    This worked great, until I made several dropdown menu selections in the same preview session and the form started collapsing on itself, with fields overlapping, etc. Looks like a nasty InfoPath bug. RATS! Now I have no idea what to do.

    Does anyone have any ideas on how to accomplish this seemingly simple task?
  • 08-12-2005 06:16 PM In reply to

    Re: Problems setting fields based on dropdown

    I should add that I'm populating the dropdown menu with the same secondary data source. The selected option's value is then used to match a node in the secondary data source so I can retrieve the rest of the associated data.
  • 08-13-2005 08:59 AM In reply to

    Re: Problems setting fields based on dropdown

    UPDATE: The collapsing fields bug went away when I added another view to my template. I didn't change any of the OnAfterChange event handler code. Everything appears to be working fine now.

    I'm sure I could repro this issue if Microsoft is interested. I'll post into the Bugs forum to alert Greg to this issue.
  • 08-14-2005 11:03 PM In reply to

    Re: Problems setting fields based on dropdown

    Hi Patrick,
    That error is strange. I would expect rules to work fine. Maybe it's an issue with preview. Did you try publishing and testing the form from there? Anyway, I will send e-mail to MS about this. Nice bit of sleuthing! :)

    Patrick Halstead [InfoPath MVP]
    InfoPathDev
    Patrick Halstead
    Project Manager at Qdabra
  • 08-15-2005 08:52 AM In reply to

    Re: Problems setting fields based on dropdown

    I only tried it in Preview.
  • 02-14-2007 08:40 AM In reply to

    Re: Problems setting fields based on dropdown

    I'm getting the same "unspecified error" on trying to update my main view via a dropdown using 2ndary datasource values as options. Publishing didn't help. Get it on any rule that references the field expressions.
  • 02-14-2007 10:48 AM In reply to

    Re: Problems setting fields based on dropdown

    Hi JackInTheGreen,
    Can you give me a little more detail? What version of InfoPath are you using? What are the field expressions? If you are using InfoPath 2007, go to Logic Inspector under Tools and reply with a list of the rules you have defined. More soon,
    Patrick Halstead
    Project Manager at Qdabra
  • 02-14-2007 11:35 AM In reply to

    Re: Problems setting fields based on dropdown

    Hi Patrick, sorry for the lack of background. here's the post I originally added to newbie forum.

    <excerpt>
    Any way to effectively debug a dropdown control's "Some rules not applied. Unspecified error" error? I've got a dropdown that's bound to my main datasource, but populates its options from a secondary data source; which all works fine. But I'm finding that when I apply a rule that depends on a field expression(executes xpath) and then preview the form, no matter which action applied - condition added or no, I get the above uninformative error. I'm using IP 2003 with c# managed code, BTW.
    </excerpt>

    This looks like a managed code thing since I'm getting the same error as the other Patrick trying to do almost precisely the same thing, except I'm using c#. But it looks like he was successfully able to access and handle the OnAfterChange event type from his form code, whereas I cannot; at least not wit this handler; throws an error when I select from the dropdown (ctrl80's the dropdown):

    [InfoPathEventHandler(MatchPath = "CTRL80", EventType = InfoPathEventType.OnAfterChange)]
    public void CTRL80_OnAfterChange(DocActionEvent e)
    {
    thisXDocument.UI.Alert("I'm here");// testing handler
    }

    Any ideas? Thanks!!
  • 02-14-2007 11:52 AM In reply to

    Re: Problems setting fields based on dropdown

    Do you have any rules defined on the dropdown? Can you double click on the dropdown and choose Rules and Custom Code and tell me what you have?

    For OnAfterChange event handlers you should have code that short-circuits processing if you are in a undo event. This is pretty common. I don't think that InfoPath is stopping as a result of unlimited percolation of events, but it's possible. If so, just add the line to the top of your OnAfterChange event to return if the event is an Undo event.

    Anyway, need more information.
    Patrick Halstead
    Project Manager at Qdabra
  • 02-15-2007 07:07 AM In reply to

    Re: Problems setting fields based on dropdown

    I Got it!!

    My mistake was trying to handle the event based on the control ID when I should have been handling the change in the dataobject DOM. Thanks for your help!, it got me looking on the right track, then found a good example on MSDN.

    Cheers!
  • 02-16-2007 12:57 AM In reply to

    Re: Problems setting fields based on dropdown

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