Restricting user form deleting node in repeating section but not adding - InfoPath Dev
in

InfoPath Dev

Restricting user form deleting node in repeating section but not adding

Last post 01-20-2009 06:53 AM by guptasourav. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 01-16-2009 04:22 PM

    Restricting user form deleting node in repeating section but not adding

     Hi,

    I am using a browser enabled form in Infopath 2007. I want to restrict some users depending upon the role. The restriction is, I do not want to delete node from repeating section but they can add more. In Infopath there is option to restrict both adding and deleting simultaneously.

    Is there a way where I can restrict user from deleting but not adding new item in the repeating section.

    Can we do some thing on Repeatingsection_Changed event to restrict?

     Thanks 

    Thanks
    Sourav
  • 01-16-2009 09:56 PM In reply to

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

    Re: Restricting user form deleting node in repeating section but not adding

    Hello,

    We can restrict depend on e.operation value. If e.operation is equal to ‘delete' then you have to write the below code,

    public void group2_Changing(object sender, XmlChangingEventArgs e)

    {

    if (e.Operation.ToString() == "Delete")

    {

    e.CancelableArgs.Cancel = true;

    }

    }

    Using above code you will get one message.

  • 01-16-2009 10:35 PM In reply to

    Re: Restricting user form deleting node in repeating section but not adding

     Thanks Shiva for the reply,

    But I cannot see  XmlChangingEventArgsXml event in my code behind. Do I need to add that manually? I even tried to add that manually but there is no such  event handler present except validating and changed.

     

    Thanks
    Sourav
  • 01-16-2009 11:22 PM In reply to

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

    Re: Restricting user form deleting node in repeating section but not adding

    Hello,

    We have three events like changing, validating and changed. In these you have to choose ‘changing' event. To inset this event select the repeating section node,

    1. Go to properties - > Programming.

    2. Select ‘Changing Event..' event

    Then it will insert the changing event for your code.

  • 01-17-2009 08:23 AM In reply to

    Re: Restricting user form deleting node in repeating section but not adding

     This is strange but I can see only Changed and validating events only. There is no changing event in it.

    Are you using Infopath 2003? I am using Infopath 2007 and cannot see this option 

    Thanks
    Sourav
  • 01-19-2009 08:36 AM In reply to

    Re: Restricting user form deleting node in repeating section but not adding

     Hi Shiva,

    Does events depend upon Browser and Client forms. I can see changing event as you said but it is disabled. Do you know some way to make that enable.

    I have this class when i go to definition on changed event. Do you get the same thing.

    using System;

    namespace Microsoft.Office.InfoPath
    {
        // Summary:
        //     Implements the events raised by changes to the data in the underlying XML
        //     document of a form instance.
        public abstract class XmlEvent
        {
            protected XmlEvent();


            public abstract bool RaiseUndoRedoForChanged { get; set; }

            public abstract event XmlChangedEventHandler Changed;
          
            public abstract event XmlValidatingEventHandler Validating;
        }
    }

    Thanks
    Sourav
  • 01-20-2009 01:19 AM In reply to

    Re: Restricting user form deleting node in repeating section but not adding

    Hi,

    You can directly add the changing event for a field. Follow the below steps.

    1. In your code you will see InternalStartup() method. In this method write the following.

    EventManager.XmlEvents["xpath of your repeating node"].Changing += new XmlChangingEventHandler(repeatingfieldname_Changing);

     

    Ex: EventManager.XmlEvents["/my:myFields/my:group3/my:group4"].Changing += new XmlChangingEventHandler(group4_Changing);

    2. After adding the above, add the changing event method.

     public void repeatingfieldname _Changing(object sender, XmlChangingEventArgs e)

    {

     Write your code

    }

     

    Ex:

    public void group4_Changing(object sender, XmlChangingEventArgs e)

    {

     Write your code here

    }

    Swathip
    www.ggktech.com
  • 01-20-2009 06:53 AM In reply to

    Re: Restricting user form deleting node in repeating section but not adding

     Hi Swathip,

    This is not working for me.  The changing event only works when you have client form.This does not comes with browser. I have already posted that in the XMLEvent class there are only 2 events Changed and Validating and there is no changing event. Therefore when I manually add event handler it gives me this error : "add the type or namespace "XmlChangingEventArgs" could not be found"

     The XMLEvent class shows the following :

    using System;

    namespace Microsoft.Office.InfoPath
    {

        public abstract class XmlEvent
        {
            protected XmlEvent();


            public abstract bool RaiseUndoRedoForChanged { get; set; }

            public abstract event XmlChangedEventHandler Changed;
          
            public abstract event XmlValidatingEventHandler Validating;
        }
    }

     

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