Delete a SharePoint Library Item from an Infopath form - InfoPath Dev
in

InfoPath Dev

Delete a SharePoint Library Item from an Infopath form

Last post 02-13-2017 11:55 AM by Hilary Stoupa. 12 replies.
Page 1 of 1 (13 items)
Sort Posts: Previous Next
  • 02-09-2017 03:22 PM

    Delete a SharePoint Library Item from an Infopath form

    Hello everyone.

    This is what I am trying to do:

    I have a form which Name on submitting is an ID + Part/Number. I am submitting allowing overwrite previous file. However, the Part/Number needs to change once the form has been submitted and therefore the Name will also change. On submit, the event is creating a new updated form in my SharePoint Library, which is good. But the old form with the previous Name is still there. So I want to delete that previous form after creating the new one.

    So basically I am asking for help on how to delete an item in my Sharepoint Library which is triggered by an event in my Infopath form. I read this: here but that solution involve coding. I don't have tools available to coding. So I am looking for a codeless solution for this problem. Anyone please help... I would appreciate any suggestion!!

  • 02-09-2017 03:37 PM In reply to

    Re: Delete a SharePoint Library Item from an Infopath form

    Can you use a SharePoint workflow? Maybe promote another field from your form that has the "old name" in it - on submit, if there is a value, the workflow tries to delete the form w/ that name?
    Hilary Stoupa

  • 02-10-2017 06:34 AM In reply to

    Re: Delete a SharePoint Library Item from an Infopath form

    Hilary. Thanks for your answer.
    Unfortunately, I am not able to use workflows. :(
    Is there a way to do it with rules?
  • 02-10-2017 08:40 AM In reply to

    Re: Delete a SharePoint Library Item from an Infopath form

    Yes, I think so - but it isn't easy..... Basically, you have to create an XML that has the correct CAML for deleting, and then have a web service connection to submit that to the Lists web service. I have a few forms that use this approach for deleting list items, and I'd assume it would work for libraries as well. I'll try to put together a simple sample for you later today - although you'll have to update data connections to point to your library, add a query to get back the list item ID from your library, etc.
    Hilary Stoupa

  • 02-10-2017 04:42 PM In reply to

    Re: Delete a SharePoint Library Item from an Infopath form

    Here's a sample. Save it locally, right click and select design. I've added some instruction & information. Please note that this won't work in an Office365 browser form as it uses the lists web service that SharePoint won't allow. But I guess if you are on Office365, you could probably use MS Flow. :)
    Hilary Stoupa

  • 02-13-2017 08:00 AM In reply to

    Re: Delete a SharePoint Library Item from an Infopath form

    Hi Hilary,

    Thank you for your help. I don't have Office 365.
    I am still not able to get it working. I updated the URL in the data connection. Here is what I am doing:
    List Name = I tried with the list name in the top of my library, but I got an error about the GUID. Then, I tried with the GUID of the library 1905J6CB-3F05-4746-87B8-5C9CB3E2C7E6
    ID Field = the ID of the specific item/file in my SP Library, in my case "63"
    FileRef Field = http://teamspace/et/mysite/mylibrary/63_789-A.xml, where 63_789-A is the Name that is shown in my SP Library

    I click Submit, but the file is still there. Not deletion done. Any hint what I am doing wrong?
  • 02-13-2017 08:46 AM In reply to

    Re: Delete a SharePoint Library Item from an Infopath form

     Can you install Fiddler on your machine? It is a free download - you can run it while you try your logic to delete and in the Inspectors section you can get back info that may help us see what's going wrong. Want to give it a try?

    Hilary Stoupa

  • 02-13-2017 10:08 AM In reply to

    Re: Delete a SharePoint Library Item from an Infopath form

    Hi Hilary
    I installed the app you told me, run it, and tried again to delete the item based on the Infopath form you provided me.

    This is what I got in the Inspectors tab:
    POST http://teamspace/et/printed_circuit_design/initialrelease/_vti_bin/lists.asmx HTTP/1.1
    SOAPAction: "http://schemas.microsoft.com/sharepoint/soap/UpdateListItems"
    Content-Type: text/xml; charset="UTF-8"
    User-Agent: SOAP Toolkit 3.0
    Host: teamspace
    Content-Length: 827
    Connection: Keep-Alive
    Pragma: no-cache
    Cookie: WSS_KeepSessionAuthenticated=80; MSOWebPartPage_AnonymousAccessCookie=80
    (?xml version="1.0" encoding="UTF-8" standalone="no"?)(SOAP-ENV:Envelope xmlns:SOAPSDK1="http://www.w3.org/2001/XMLSchema" xmlns:SOAPSDK2="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAPSDK3="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/")(SOAP-ENV:Body)(tns:UpdateListItems xmlns:tns="http://schemas.microsoft.com/sharepoint/soap/")(tns:listName)1905F6CB-3F05-4746-87F8-5C9CB3E2C7E6(/tns:listName)(tns:updates)(Batch OnError="Continue")
    		(Method ID="Delete" Cmd="Delete")
    			(Field Name="ID" set="")63(/Field)
    			(Field Name="FileRef" set="")http://teamspace/et/printed_circuit_design/initialrelease/New%20Engineering%20Checklist%20Dev%20Test/63_789-A.xml(/Field)		
    		(/Method)
    	(/Batch)(/tns:updates)(/tns:UpdateListItems)(/SOAP-ENV:Body)(/SOAP-ENV:Envelope)
    


    I replace '' with '(' and ')', just because I don't know how to make view able.
    Any hint?
  • 02-13-2017 10:15 AM In reply to

    Re: Delete a SharePoint Library Item from an Infopath form

    In the inspectors tab, you should have a request and a response. The above looks like your request and it looks like it should be okay - so check the XML in the response tab and see what's there. :)
    Hilary Stoupa

  • 02-13-2017 10:37 AM In reply to

    Re: Delete a SharePoint Library Item from an Infopath form

    Thank you Hilary for this follow up. I am learning a lot here. Please don't give up on me.
    This is part of the xml response :
        Result [ ID=Delete,Delete ]
    
        Error Code 
            0x81020030 
        Error Text 
            Invalid file name The file name you specified could not be used.  It may be the name of an existing file or directory, or you may not have permission to access the file. 

    I am not sure about the FileRef. I am putting there the path of the library + what is found under the column "Name" + ".xml"... Is that right?
  • 02-13-2017 11:28 AM In reply to

    Re: Delete a SharePoint Library Item from an Infopath form

     You are doing great - there is a lot to learn - like I said, this isn't exactly easy stuff. So we have to figure out why it is failing. Name + .xml should be right.

    I did a search online and turned up this post:  http://www.infopathdev.com/forums/t/30817.aspx

    Looks like I've had the same issue before with an encoded URL - so maybe try replacing the %20 in your URL with spaces?

    http://teamspace/et/printed_circuit_design/initialrelease/New Engineering Checklist Dev Test/63_789-A.xml 

     

    Hilary Stoupa

  • 02-13-2017 11:46 AM In reply to

    Re: Delete a SharePoint Library Item from an Infopath form

    Great!!!
    Finally it works.. thank you so much!!!
  • 02-13-2017 11:55 AM In reply to

    Re: Delete a SharePoint Library Item from an Infopath form

    Whoo hoo! way to start the week. :)
    Hilary Stoupa

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