How to set a number format for a InfoPath form (when setting fields using rules) - InfoPath Dev
in

InfoPath Dev

How to set a number format for a InfoPath form (when setting fields using rules)

Last post 08-12-2013 12:36 AM by Trevor Arter. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 08-08-2013 07:45 AM

    How to set a number format for a InfoPath form (when setting fields using rules)

    Hi Experts

    I have an an InfoPath 2007 form (submitting to SharePoint 2007) which needs to work in an international environment where some PC's have European regional settings, and some have US/UK settings.

    I have a button which when clicked sets a field's value to a value called UpgradeFactor which is fetched from a secondary data source (configuration list on the same SharePoint site)

     xPath for the rule:

    (set a fields value to...) 

    xdXDocument:GetDOM("FormConfig")/dfs:myFields/dfs:dataFields/dfs:FormConfig/@FieldValue[../@FieldName = "UpgradeFactor"]

    UpgradeFactor is a decimal value between 0 and 1, currently set to "0.25" and the field which receives it is has type Decimal (Double)

     This works fine on a PC with US or UK regional settings, but on a European one I get a validation error because of wrong data format (expecting "0,25").

     How can I make the form always work with US number format?

    I've already set the SharePoint site to US regional settings. I've added a culture to the form code which works fine for the code but doesn't seem to affect rules or the rest of the form:

    CultureInfo culture = new CultureInfo("en-GB");

    I've also tried setting the value to 25 and modifying the xPath with something like "25div100" but that didn't seem to work either.

    Can anybody help?

     Thanks

    Trevor

     

     

  • 08-10-2013 10:57 PM In reply to

    Re: How to set a number format for a InfoPath form (when setting fields using rules)

    Is this happening in a browser form or within the InfoPath filler? What are you using to query the data from SharePoint?

    I suspect what may be happening is that SharePoint may be returning region-formatted data (e.g. 0,25) and that you are getting the validation error when the 0,25 value is set to the field, because it is not a valid XML number.

    One way to check this is to display the value in an Expression Box with the formatting set to None.

    If the number will always be between 0 and 1 (i.e. won't have any thousands separators), one thing you can do is use translate() to convert the commas to periods:

    translate(xdXDocument:GetDOM("FormConfig")/dfs:myFields/dfs:dataFields/dfs:FormConfig/@FieldValue[../@FieldName = "UpgradeFactor"], ",", ".")

    Could you give that a try?

    Incidentally, 25 div 100 should work, but you need to put spaces between the numbers and the div.

    Patrick Halstead
    Project Manager at Qdabra
  • 08-12-2013 12:36 AM In reply to

    Re: How to set a number format for a InfoPath form (when setting fields using rules)

    Solved it using

     number(xdXDocument:GetDOM("FormConfig")/dfs:myFields/dfs:dataFields/dfs:FormConfig/@FieldValue[../@FieldName = "UpgradeFactor"]) div 100

    Thanks for your help.

    (It was in the InfoPath 2007 client, using a button click to query a SharePoint list)  

    Do you know where I can find a good description of the syntax of these xPath functions for use in rules?

    Regards

    Trevor

     

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