Afterchange code looping - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Afterchange code looping

Last post 08-28-2007 10:02 AM by Agni Jonnalagadda. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 08-28-2007 06:27 AM

    Afterchange code looping

    Hello,

    i am having problems with an afterchange event on a date field with a confirm dialogue, the code is as follows:

    function msoxd_my_Overall_Implementation_Date:nAfterChange(eventObj)

    {

    if (eventObj.IsUndoRedo)

     

    {

    }

     

    var resp = XDocument.UI.Confirm("Are you sure you want to commit to this date?",4);

    var objDataElement = XDocument.DOM.selectSingleNode("/my:myFields/my:field116");

    objDataElement.text = resp;

    }

    The problem we are encountering is that the code loops through twice, the first time it makes the field required, then the second it adds the date, is anyone aware of a way to fix to this matter?

     

    Thank you

    Ben

  • 08-28-2007 09:23 AM In reply to

    Re: Afterchange code looping

    I don't have a lot of experience with this but I think it's because of the way the DOM works. For onAfter and before changes fire twice. One for insert and one for delete. This is covered in Patrick Halsteads book so if you're going to be doing a lot of custom work I highly recommend it. The jist of it is you have to filter out one of the events. For instance

     If (e.Operation = "Insert") Then

        do something

    End if

     Do something will fire only on the insert and not for delete. I hope that made sense. Good luck!

    Shaun Nieves
    Sharepoint Manager
  • 08-28-2007 10:02 AM In reply to

    Re: Afterchange code looping

    You need to validate your code well here, becuase when you empty a field only "Delete" event gets fired. If you need to perform some operations even when the node becomes empty then you need to have another if condition for "Delete" operation.

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