Avoid saving a form in SharePoint with same name - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Avoid saving a form in SharePoint with same name

Last post 05-12-2018 04:24 AM by azadeh. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 12-27-2006 03:28 AM

    • zaphi
    • Top 100 Contributor
    • Joined on 01-09-2006
    • Switzerland
    • Posts 82

    Avoid saving a form in SharePoint with same name

    Hi
    I have a form that I want to save in a SharePoint Form Library. The filename is built automatically with fields of the form.

    If the form is new, and the filename already exists, a warning should be prompted and the save-action should be interrupted. If the file is not new, it must be saved with the same name.

    I already tried to do it by submitting the form with a data connection. But I can only choose if the file can be overwriten or not. I need actually a conditional way.

    I use a button and code in JScript.

    Thank you for your help.

    Best regards.
    Philippe




    Infopath 2007/SP2
  • 12-27-2006 05:52 AM In reply to

    Re: Avoid saving a form in SharePoint with same name

    Hi

    Take a data connection submitting to SharePoint library with 'File name' field insert the field that you want to display as file name. I did in the following way and it worked fine for me

    1. Open InfoPath form in design mode
    2. Take submit data connection to the share point library
    3. Enter share point library name and insert the field that you want to display the file name in 'File Name' field
    4. Click 'Next' and click 'finish'
    5. On ‘Submit#%92 take the data connection and save the form
    Madhuri
    http://www.ggktech.com
  • 12-27-2006 07:37 AM In reply to

    • zaphi
    • Top 100 Contributor
    • Joined on 01-09-2006
    • Switzerland
    • Posts 82

    Re: Avoid saving a form in SharePoint with same name

    Hi,
    Thank you for your help, but I am afraid, it is not exactly the answer to my problem.

    My form has to meet two conditions:

    1. Avoid, that the new form will be saved with the same name as a form that already exists, because the old one would be overwritten.
    2. The form must be saved several times in its life (after signing through several people)

    I hope you can help me more.
    Best regards.
    Philippe
    Infopath 2007/SP2
  • 12-28-2006 11:27 PM In reply to

    • Mahitha
    • Top 200 Contributor
    • Joined on 05-24-2005
    • India
    • Posts 57

    Re: Avoid saving a form in SharePoint with same name

    If you use GUID number as a file name for your form then , new form is created on every submit. You need to uncheck the check box "Allow Overwrite if file exists" in Data connection wizard.
  • 11-15-2007 12:27 PM In reply to

    • huffe
    • Not Ranked
    • Joined on 11-08-2006
    • USA
    • Posts 1

    Re: Avoid saving a form in SharePoint with same name

    I am currently trying to do this however I keep getting the following error. I'm sure it is something in the data connections, and the "read-only" field that has been inserted into the form. Please advise if I inadvertantly missed something.

     ERROR:

    InfoPath cannot submit the form.
    An error occurred while the form was being submitted.
    The form cannot be submitted to the following location: ****.com/forms/Travel Customer Service/Customer Service - test2007-11-15T14_02_28.xml
    The folder does not exist.

    Thanks,

    Lisa

  • 11-26-2007 09:55 AM In reply to

    Re: Avoid saving a form in SharePoint with same name

    Hi Philippe,

    I don't know if this will help, but if you allow SharePoint to control versions of the documents on the list, all the submissions will be stored under the same file name instead of being overwritten. This should make it easier to find things and you will still be able to see a history of the document, including who submitted it and when.

    Hopefully this will make things easier for you.

  • 11-30-2007 02:40 PM In reply to

    Re: Avoid saving a form in SharePoint with same name

    So many ways to do this with JS, but the easiest is to use the Application.IsDestinationReachable method to programatically see if the file already exists in SharePoint. Try this code:

        myFileNameField = XDocument.DOM.selectSingleNode("//fileNameField").text;

        myURL = "http://mySite/library/"+myFileNameField + ".xml";

        if (Application.IsDestinationReachable(myURL)) submitFormWithMySubmitConnection();

        else XDocument.UI.Alert("file name already exists");

     

    You could also create a new data connection to the library to receive data from a SharePoint library or list and traverse the list to see if the file name already appears, but I think that's a bit code heavy.

  • 05-12-2018 04:24 AM In reply to

    • azadeh
    • Not Ranked
    • Joined on 08-15-2017
    • Posts 6

    Re: Avoid saving a form in SharePoint with same name

    hi where should I write this code
Page 1 of 1 (8 items)
Copyright © 2003-2018 Qdabra Software. All rights reserved.
View our Terms of Use.