Changing field value in JScript - InfoPath Dev
in

InfoPath Dev

Changing field value in JScript

Last post 11-21-2007 11:59 AM by 10basetom. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 11-13-2007 08:04 PM

    Changing field value in JScript

    Hello,

    I have a field named FirstName that has an OnAfterChange event handler. In this event handler I would like to make sure that the FirstName value is in sentence casing (i.e., "tom" or "TOM" would be corrected to "Tom"). My question is, what is the best way to update the FirstName field with the corrected value?

    I know that I can just change XDocument.DOM.selectSingleNode("my:myFields/my:FirstName").text, but is there another way to do this that doesn't require knowing the XPath? What I have in mind is to change a property equivalent to eventObj.Site.text or eventObj.NewValue.

    Thanks,
    Tom

    UPDATE: After further research I found out that I needed to set a Boolean flag in order to prevent infinite loops in the OnAfterChange event handler (thanks to Greg Collins' article). Now I can change the field value by updating either XDocument.DOM.selectSingleNode(eventObj.MatchExpression).text or eventObj.Site.text.
  • 11-21-2007 08:25 AM In reply to

    Re: Changing field value in JScript

    Hi 10basetom,

    Looks like you got it working... grats!  Are you sure eventObj.Source.text is read-only?

    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 11-21-2007 11:59 AM In reply to

    Re: Changing field value in JScript

    Hi Matt, Thanks for the correction. In fact, my solution involved something similar (writing to eventObj.Site.text). I'll edit my post to reflect this. Tom
Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.