Testing for numeric or nil values in form template

I have a form where I need to perform a calculation on the "UnitPrice", which is passed in the XML. Normally, this works fine. There are some cases, however, where pricing is supressed. In these cases, the UnitPrice comes over nilled:

  <UnitPrice xsi:nil="true"/>

This causes an error in the form and will not generate. I had tried, with no success, to come up with a way to handle this previously in XPath. I finally gave up and waited for the new scripting functionality to be release, but I cannot seem to come up with a way to do this in scripting, either. Any thoughts on how to perform this calculation only if UnitPrice has a valid numeric value?

As a side note, while working this issue, I did come across what I believe to be a bug in the scripting engine, and I have opened a ticket. The issue is with the "length" function, which is a documented, supported function.

length("abc") returns a 3 as expected

length("ab3") also returns 3 as expected

length("123") will throw an error (Yes, it is a number, but it is being presented a string, in quotes, that just happens to be a number).

length("1.23") will also throw an error

Best Answer

  • Aaron Roma
    Aaron Roma Member Posts: 4
    Answer ✓

    I don't really have any control of the XML, as it is coming straight out of the ERP application. (Baring writing some sort of extension to the print process, which is beyond my pay grade.

    I've actually was able to come up with a working solution via the scripting in the new Word Addin, though it's a bit kludgy. I can clean it up a bit if they fix the above-mentioned bug. It does work for now.

Answers