Repeating Section : want to simulate onModify() functionality - InfoPath Dev
in

InfoPath Dev

Repeating Section : want to simulate onModify() functionality

Last post 12-29-2008 07:17 PM by Shiva. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 12-24-2008 10:04 AM

    Repeating Section : want to simulate onModify() functionality

    I have a repeating section (a database table) which has a field called "ChangeIndicator".  I need to populate it with some value (e.g 0 or 1) based on whether on not the existing text in any of the fileds changed or not.  So basically I need to set a flag when some text changes.

     Can it be done relatively simply in InfoPath 2003?

  • 12-24-2008 09:21 PM In reply to

    Re: Repeating Section : want to simulate onModify() functionality

    Hi,

    Put an on after change event for the repeating section. If any value changes in the repeating section then set the change Indicator value to 1.

    Swathip
    www.ggktech.com
  • 12-25-2008 05:57 PM In reply to

    Re: Repeating Section : want to simulate onModify() functionality

    swathip:

    Hi,

    Put an on after change event for the repeating section. If any value changes in the repeating section then set the change Indicator value to 1.

     

    Hi Swathi,

    How do I do that? I mean in InfoPath 2003, can you tell me how to add this On After Change event?  Does it involve any coding?  If yes, can you send me a code snippet?  I would ideally want to do this without any code.  Can you provide some inout in that direction?

    Thanks,

    Shivaji

  • 12-25-2008 09:42 PM In reply to

    Re: Repeating Section : want to simulate onModify() functionality

     

    Hi,

    You can add an on after change event by following the below steps.

    1. Go to data source and right click on the repeating group.

    2. Click on Programming -> on after change.

    3. And write the following code line in the on after change.

    If(e.NewValue != e.OldValue  && e.OldValue != null)

     {

     thisXDocument.DOM.selectSingleNode("xpath of change indicator field").text = 1;

     }

    Swathip
    www.ggktech.com
  • 12-26-2008 08:35 PM In reply to

    Re: Repeating Section : want to simulate onModify() functionality

    swathip:

     

    Hi,

    You can add an on after change event by following the below steps.

    1. Go to data source and right click on the repeating group.

    2. Click on Programming -> on after change.

    3. And write the following code line in the on after change.

    If(e.NewValue != e.OldValue  && e.OldValue != null)

     {

     thisXDocument.DOM.selectSingleNode("xpath of change indicator field").text = 1;

     }

     

    Hi Swathi,

    I think I am almost there.  When I change the value, I am getting a runtime error saying "e" is undefined (which I understand is a valid error as I have not defined "e").  How do I define "e"? My code looks like :

    function msoxd_my_group2::OnAfterChange(eventObj)

    {

    If(e.NewValue != e.OldValue && e.OldValue != null) { thisXDocument.DOM.selectSingleNode("../my:field6").text = 1; } // Write code here to restore the global state.

    if (eventObj.IsUndoRedo)

    {

    // An undo or redo operation has occurred and the DOM is read-only. return;

    } // A field change has occurred and the DOM is writable. Write code here to respond to the changes.

    }

  • 12-28-2008 10:19 PM In reply to

    • Anuma
    • Top 25 Contributor
      Female
    • Joined on 07-20-2005
    • India
    • Posts 525

    Re: Repeating Section : want to simulate onModify() functionality

    Hi,

    Verify below code. Define "e" in your function.

    function msoxd_my_group2::OnAfterChange(eventObj e)

    {

    }

    Anuma Chinthapalli /
    http://www.GGKTech.com
  • 12-29-2008 01:46 AM In reply to

    • Shiva
    • Top 25 Contributor
    • Joined on 04-15-2005
    • India
    • Posts 694

    Re: Repeating Section : want to simulate onModify() functionality

    Hello,

    In Swathi code, e is equal to ‘eventObj' in your code. You have to replace ‘eventObj' in the place of ‘e' in above code.

    Here is the code,

    function msoxd_my_group2::OnAfterChange(eventObj)

    {

    if(eventObj.NewValue != eventObj.OldValue  && eventObj.OldValue != null)

    {

    XDocument.DOM.selectSingleNode("XPath of change indicator field").text = 1;

    }

    }

  • 12-29-2008 06:31 PM In reply to

    Re: Repeating Section : want to simulate onModify() functionality

    Swathi, Shiva and Anuma,

    Thank you very much for your help.  I really appreciate it.  However, there seems to be some issue when I launch the form.  It says ')' expected at the beginning of the code section.  I have tallied the open and closed brackets and they match. 

    Just FYI:

    1.  The scripting is set to JScript.

    2.  I am using IP 2003.

    3.  I have declared the 'e' as eventObj e.

    Any further help in this regard will be great.  I will attach a dummy form with the thing I am trying to do.  Maybe you guys can take a look at it, and suggest modifications / corrections.

    Thanks,

    Shivaji

  • 12-29-2008 07:17 PM In reply to

    • Shiva
    • Top 25 Contributor
    • Joined on 04-15-2005
    • India
    • Posts 694

    Re: Repeating Section : want to simulate onModify() functionality

    Hello,

    No need to declare 'eventObj' object is 'e'. You have to use whichever generated object name in JScript and that is 'eventObj' in your code.

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