z-on

What am I doing wrong here I have an Infopath form with a drop-down listbox, that is poulated with manually-entered values.

I choose a value, submit the updated data, and it does put the correct value in the SQL 2005 database.
However, the next time I query the same data, the value in the drop-down list box is the default value
for the list-box, not the value from the database, which is misleading.

I would have expected the drop-down listbox to display the value from the database instead. Thanks.



Re: SharePoint - InfoPath Forms Services InfoPath drop-down listbox w/manually entered values - display wrong on query

SSAhmed

How do you query the data Where do you save the form In SharePoint, in local folder






Re: SharePoint - InfoPath Forms Services InfoPath drop-down listbox w/manually entered values - display wrong on query

Paul Galvin

It does seem counterintuitive.

I would try adding a rule that fires when the form opens. Query the database data source and assign the DB value from the database to the drop-down.

I don't have infopath client on this machine so I can't test, but I think that if you go to Tools -> Form Options, you can find a place to write rules that fire when the form opens.

Regards,

--Paul Galvin






Re: SharePoint - InfoPath Forms Services InfoPath drop-down listbox w/manually entered values - display wrong on query

SSAhmed

If you are storing the form in SharePoint then you dont need to worry about it. It will be handled automatically otherwise, as Paul said, you will have to manage it yourself. Yes, you can create a rule on form opening and you can also check programmatically if new form is opened or an old form is opened for editing. If it's an old form then you can retrieve the value from the db and set it in dropdown. Some tips for you:

Check if the form is opened in edit mode:

////

if (e.InputParameters.ContainsKey("XmlLocation"))
{

//retrieve value from db and set dd value

}

////

Put this code in form's loading event.

setting the value of the dd:

XPathNavigator DOM = this.MainDataSource.CreateNavigator();

XPathNavigator dropdown = DOM.SelectSingleNode("/my:myFields/my:yourDDName", this.NamespaceManager);


dropdown.SetValue(ValueFromDB());

http://sharepointblogs.com/ssa

MOSS MVP