"Attempt to modify a read-only node" error when setting field - InfoPath Dev
in

InfoPath Dev

"Attempt to modify a read-only node" error when setting field

Last post 05-31-2009 07:59 PM by sreid1. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 05-28-2009 11:08 PM

    • sreid1
    • Not Ranked
    • Joined on 05-28-2009
    • Posts 3

    "Attempt to modify a read-only node" error when setting field

    Hey Everyone,

    I'm having a problem which is driving me crazy, so hopefully someone can help me.

    I have a drop-down list on a form, which I have added a rule to so that when the value changes, some code-behind c# code is called. This c# code calls a webservice to retrieve some data based on the user selection. All that works fine, and the data is retrieved successfully.

    When I try and update the appropriate field, however, I get an exception saying "Attempt to modify a read-only node". I have checked the field, and I can update it manually no problem. If I check the node itself before setting the value the "CanEdit" bool is set to "True". The last puzzling thing is that this code works fine for setting fields during the on load event.

    This is the code I'm using to try and set the value of the field:

    PathNavigator xnMyForm = MainDataSource.CreateNavigator();
    xnMyForm.SelectSingleNode("//my:" + fieldName, NamespaceManager).SetValue(param);

    The rule I'm using only has a condition which is "The expression" and xdExtension:UpdateFields()". I don't think this is the problem though, as the method is being called correctly.

    If anyone can help me out with a solution, or how to investigate this problem further, I'd be most grateful.

    Cheers -- Stuart

  • 05-31-2009 11:34 AM In reply to

    Re: "Attempt to modify a read-only node" error when setting field

    Hi Stuart,

    I'm not sure exactly why you are using code. You should be able to do this without code using rules and actions to query the Web service and set values based on it. If you have written code in an OnAfterChange event handler it's possible that InfoPath locks the field that caused the event to fire since that would produce another call to the event handler. :) 

    Patrick Halstead
    Project Manager at Qdabra
  • 05-31-2009 04:19 PM In reply to

    • sreid1
    • Not Ranked
    • Joined on 05-28-2009
    • Posts 3

    Re: "Attempt to modify a read-only node" error when setting field

    Hi Patrick,

    I'm using code as I'm pretty new to the whole Infopath thing. I came across an article online somewhere which had this way of doing things, so I was apeing that.

    I didn't realise I can do it all with rules and actions, so I'll look into that way instead. I'd prefer to steer away from the code-behind as much as possible, so that's great! Thanks for the suggestion.

    If I have any other problems/questions I'll post them.

    Thanks again -- Stuart

  • 05-31-2009 07:59 PM In reply to

    • sreid1
    • Not Ranked
    • Joined on 05-28-2009
    • Posts 3

    Re: "Attempt to modify a read-only node" error when setting field

    Hey Patrick,

    As a followup to my other message this morning. You were right! Adding in the rules instead of using the code-behind has fixed all the problems. Plus it allowed me to set a bunch of fields with only one call, so I'm extra happy today.

    Thanks again for your help!

    Cheers -- Stuart

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