switch to edit mode on button click - InfoPath Dev
in

InfoPath Dev

switch to edit mode on button click

Last post 07-15-2011 08:10 AM by leoffneym. 22 replies.
Page 2 of 2 (23 items) < Previous 1 2
Sort Posts: Previous Next
  • 07-06-2011 01:12 PM In reply to

    Re: switch to edit mode on button click

    Sorry, I forgot some info that needs to done with updates.

    In the xml that you had to create to for the Batch, add <Field Name='ID'></Field> above all the other fields.
    The ID is unique to each row in the SP List, in order to update the row, you will need the ID of that row, which can be gotten from the data source the same way you pull all the other info.

    In order to update, just like when you add, you just set all the fields necessary and the ID field to the ID that you got when you queried the SP List.

    To make it all work fluently and to have integrate with your existing form will be the fun part.
    You can either:

    • Have the query populate the CAML repeating table and update it there
    • Or use code and use your own fields.

    The choice is up to you,  I use code only because we already have custom code on our forms and implementing it make it flow better, but both ways work the same.

  • 07-07-2011 07:21 AM In reply to

    Re: switch to edit mode on button click

    I tried adding the ID field to the xml file but it still didn't updatethe record. Do I have to add the ID field to the form as well? Whenyou say I need to set the record to the ID of the recordwhat exactly do you mean? Do you have any examples on how to update via code? Chances are I'm not going to use a repeating table so I'm hoping I'll be able to do this without a repeating table.
  • 07-07-2011 11:34 AM In reply to

    Re: switch to edit mode on button click

    i tried adding the ID field (was in a meeting all day and just got to it now) and that didnt work, so I'm still not sure why its not updating :(

    >>>> Or use code and use your own fields.

    i think this is the direction I should head in, as I'm only going to want one record to show up on the screen. Any resources you can point me in would be most appreciated!

  • 07-11-2011 02:31 PM In reply to

    Re: switch to edit mode on button click

    just wanted to check in and see if you had any suggestions for this.

     Cheers
    Josh

  • 07-13-2011 01:55 PM In reply to

    Re: switch to edit mode on button click

    just an update here:

     I've noticed if I hard code values in the xml file, it does do the update, it just doesnt update when i try updating the fields.

    i've also been trying to get this to work via code following the example from here:

    http://msdn.microsoft.com/en-us/library/ms440289(v=office.12).aspx

    Unfortunately it blows up on the last line (go figure!), and says:

    "Request for the permission of type 'System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."

    my code is as follows:

    'Declare and initialize a variable for the Lists Web service.

    Dim listService As New spWeb.Lists()

    'Authenticate the current user by passing their default

    'credentials to the Web service from the system credential cache.

    listService.Credentials = System.Net.CredentialCache.DefaultCredentials

    'Set the Url property of the service for the path to a subsite.

    listService.Url = "http://server.com/Dev/_vti_bin/lists.asmx"

    'Get Name attribute values (GUIDs) for list and view.

    ' Dim ndListView As System.Xml.XmlNode = listService.GetListAndView("WirelessDev", "")

    Dim strListID As String = "{F5BBD9F7-7FA5-41C3-A7BE-9D83B0E939FA}"

    Dim strViewID As String = "{903EC723-BAF9-4021-9BF0-FC031B430AFF}"

    'Create an XmlDocument object and construct a Batch element and its 'attributes. Note that an empty ViewName parameter causes the method 'to use the default view.

    Dim doc As New System.Xml.XmlDocument()

    Dim batchElement As System.Xml.XmlElement = doc.CreateElement("Batch")

    batchElement.SetAttribute("OnError", "Continue")

    batchElement.SetAttribute("ListVersion", "1")

    batchElement.SetAttribute("ViewName", strViewID)

    'Specify methods for the batch post using CAML. To update or delete, 'specify the ID of the item, and to update or add, specify

    'the value to place in the specified columns.

    Dim strBatch As String = "<Method ID='1' Cmd='Update'>" + _

    "<Field Name='ID'>1</Field>" + _

    "<Field Name='FirstName'>Josh</Field>" + _

    "</Method>"

    batchElement.InnerXml = strBatch

    'Update list items. This example uses the list GUID, which is recommended, but the list display name will also work.

    listService.UpdateListItems(strListID, batchElement)

    I hard coded the listID and viewIDs in, and I'm pretty confident they're correct as I got them from the URL directly in SP. From my understanding, the viewID is optional, isnt it? if none is specified, doesnt it use the default view?

  • 07-14-2011 01:23 PM In reply to

    Re: switch to edit mode on button click

    ' Dim ndListView As System.Xml.XmlNode = listService.GetListAndView("WirelessDev", "")

    Dim strListID As String = "{F5BBD9F7-7FA5-41C3-A7BE-9D83B0E939FA}"

    Dim strViewID As String = "{903EC723-BAF9-4021-9BF0-FC031B430AFF}"

    Check this section and make sure the first line here is not shown as is. It has a ' at the beginning.

  • 07-15-2011 08:03 AM In reply to

    Re: switch to edit mode on button click

    turned out it was form security, I didnt have it set to Full Trust, Once I set it to that it worked, and I now have inserting and updating functionality using pure code! any ideas why using the seperate xml file didnt work?

     Thank you again so much for your help and patience with this, its greatly appreciated! hope you have a speedy recovery with your foot surgery! 

  • 07-15-2011 08:10 AM In reply to

    Re: switch to edit mode on button click

    It may not have been setup all the way.  Any one thing off can make it fail, and it won't report why it failed.

    Happy to hear that you got it working with code.  Thats how I use it as well, code is much easier is some aspects.

    Thanks for the support with my foot, its a pain to not be able to walk, but I can still work with InfoPath. LOL.

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