Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / September 2005

Tip: Looking for answers? Try searching our database.

List values changing randomly..?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JR - 29 Aug 2005 20:33 GMT
I have a dropdown list in an Infopath form that has been giving me some grief; but I've managed to fix (or deal with) most of the problems.  However, I'm running into a very odd situation.

I have a list pulling it's contents from an XML file.  The file is on the same server as the Sharepoint site, but not part of the site itself - just in a publically accessible folder.  Everything appears to be working properly, all the values appear in the list; but when a user selects an item in the list; a different item is actually selected/displayed.  Also, it appears what is actually getting selected is random; because I can click on the same option in the list 4 times and get 4 different values.

Any ideas of what may cause this and how I go about fixing it?
Scott L. Heim [MSFT] - 30 Aug 2005 13:04 GMT
Hi JR,

I have not personally seen this behavior - maybe someone else has though. I
do have a couple of questions:

- Does the XML file contain duplicate entries?
- Is there a "unique" value field?
- Are you able to easily repro this? For instance, can you create a new,
blank InfoPath solution, take the same XML file as a data source and repro
the behavior? If so, can you provide a snippet of your XML file
structure/data and steps to repro?

Thanks JR,

Scott L. Heim
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights
JR - 30 Aug 2005 20:33 GMT
Hi again Scott;

Not all of the "values" are unique; although the display names are.

eg.

<Rate>
    <Display>Item 1</Display>
    <Value>6</Value>
</Rate>
<Rate>
    <Display>Item 2</Display>
    <Value>8</Value>
</Rate>
<Rate>
    <Display>Item 3</Display>
    <Value>6</Value>
</Rate>
..

> Hi JR,
>
[quoted text clipped - 55 lines]
>
> \par }
Scott L. Heim [MSFT] - 30 Aug 2005 21:32 GMT
JR,

I think I am reproducing what you are seeing: when I bind a List Box
control to this XML file data connection, if I click on Item 1 it will
sometimes "jump" to Item 3 - is this what you are basically describing?

If so, then this would basically be expected. Let me explain: what is
important here for InfoPath is the "value" - not necessarily the Display
Name. So when you have duplicate values in the list, InfoPath is basically
just picking one of the items as it has no way to really know which one you
want.

The best solution to this is to add a unique field so you can "uniquely"
identify each of the items in the list. Even if it is just bringing those 2
fields together so you would have: Item16, Item28 and Item36 - you could
still display what you desire but the "Values" would be unique.

Does this help?

Scott L. Heim
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights
JR - 30 Aug 2005 21:49 GMT
Hi Scott;

I was afraid you'd say that..  The main issue is that the value is a number used in a mathematical calculation (a percentage multiplier in this case), so if I was to use your example below; how would I extract the number that I actually need?

> JR,
>
[quoted text clipped - 68 lines]
>
> \par }
Scott L. Heim [MSFT] - 30 Aug 2005 22:15 GMT
How does that number get calculated? From where does this XML file get its
data? It is updated on some basis?

Scott L. Heim
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights
JR - 30 Aug 2005 22:36 GMT
All the data comes from our Finance department.  I have no idea how they arrive at the numbers but the percentage is somehow tied to the department.  So realistically, the same value could exist for more than one department.  I believe they will just manually update the file quarterly.

> How does that number get calculated? From where does this XML file get
> its  data? It is updated on some basis?
[quoted text clipped - 24 lines]
>
> \par }
Scott L. Heim [MSFT] - 01 Sep 2005 15:02 GMT
Hi JR,

Sorry for the delay as I was unexpectedly out of the office.

See if these steps work in your scenario:

- Modify your sample XML file to the following:

<?xml version = "1.0" ?>
<Rates>
<Rate>
    <Display>Item 1</Display>
    <Value>6</Value>
    <myKey>6-Item 1</myKey>
</Rate>
<Rate>
    <Display>Item 2</Display>
    <Value>8</Value>
    <myKey>8-Item 2</myKey>
</Rate>
<Rate>
    <Display>Item 3</Display>
    <Value>6</Value>
    <myKey>6-Item 3</myKey>
</Rate>
</Rates>

- Create a new, blank InfoPath solution
- Add a "Receive" data connection to the above referenced XML file named:
TestXML
- Add a drop-down list and text box to the form
- Right-click on the drop-down box and choose Properties
- Set the data connection of this control to: TestXML
- Click the Select XPath button next to Entries, select "Rate" and click OK
- Click the button next to Value Field, select myKey and click OK
- You can leave Display name as: Display
- Click OK to close this Property window
- Right-click on the text box control and choose Properties
- Click the "fx" button next to the Value field for the Default Value
- Click Insert Field or Group
- From the Data Source box choose: TestXML
- Drill down, highlight Value (under Rate) and click the Filter Data button
- Click Add
- From the first box, choose: myKey
- From the second box, choose: is equal to
- In the last box, choose: Select a field or group
- From the Data source box, choose: Main, highlight your drop-down list box
field and click OK
- Click OK 3 times to get back to the Insert Formula window - you should
basically see this: Value[myKey = field1]
- Modify this now to: Value[myKey = field1] * 10 (just to do some
mathematical function)
- Click OK 2 times to get back to your form
- Preview and test - you should be able to select any of the items in the
list and the result in the text box should change appropriately

Let me know if this works for you!!

Scott L. Heim
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights
JR - 01 Sep 2005 15:51 GMT
Hi Scott;

That's working beautifully; it's fixed all the problems with the text box values changing; but it's cropped up one other slight issue.  Until someone actually selects a value (and this is an optional field); the values calculated based on the DDL selection are all non-numbers (NaN).

This fouls up some of the other totals when this occurs.  Is there a way I can force NaN values to be zero in the calculated fields if nothing is selected in the DDL or set a default selection from the DDL?

I've also noticed a blank entry in the DDL, is that by design?

> Hi JR,
>
[quoted text clipped - 134 lines]
> \par
> \par }
Scott L. Heim [MSFT] - 01 Sep 2005 18:40 GMT
JR,

(** NOTE: You may want to read all of this before taking any action! <G>)

In that case, you can move the expression from the "Default Value" field
for the text box and use it as a "Rule" on your drop-down box:

- Right-click on your text box and choose Properties
- Click the "fx" button next to Value and "cut" the expression from the box
- Right-click on the drop-down box and choose Properties
- Click the Rules button
- Click Add
- Click Add Action
- From the Action box choose: Set a field's value
- Click the button next to Field, highlight your text box field and click OK
- Click the button next to Value and paste the expression you "cut" from
above
- Test!

In regard to the blank row, if you can use a default value from your XML
file then you can use these steps:

- Display the Data Source Task Pane
- Select Main from the Data Source drop-down
- Right-click on the node that represents your drop-down list and choose
Properties
- Set a default value (as an example, I used: 6-Item 1)

Now, the problem with using this option along with moving the expression to
a Rule is that the text box will not get populated with the value until
after a selection is made. So....after all of this <G> what I would do is
leave the expression as the "Default Value" for the text box and set one of
your options from the XML file as the default selection.

Now that I have totally confused you, let me know if this is a viable
option!

Scott L. Heim
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.