locked
Error submitting after changing filename in submit dc options RRS feed

  • Question

  • So i made a mistake a while back which is now haunting me and i need some help figuring out how to correct it. Hopefully someone here has experienced this or knows a workaround.


    A few months back, I created a form that, on submit uses a SharePoint Library Submit Data Connection. The File name setting for that DC concats the project name with the username (Which is also where my mistake lies) and if a user submits different projects with the same name, it will overwrite the previous one. I shoulda known better but was under the impression they would never put the same project name for two different projects..

    So now i need to fix it and the way i found was to use a hidden filename field and determine if the form was new or not, use a timestamp, etc. So i added this txtFilename field and changed the File name field in the Submit DC to use that field instead of the concat(projectname, userid).

    Any new projects work completely fine and the way they should, but any projects that were in the system before this update (about 3800 of them) all fail on submit and give the generic "The form cannot be submitted because of an error" message.

    I pretty much guessed this was because the txtFilename field was non existent in the xml for those forms so I started playing around with one of the old xml files and manually added the new field and updated the version but i still get the error. When i revert the Submit DC back to the old concat way, they work again but i need to get them all using the new way.

    One solution i think i could do would be to copy the files to my computer, write some code to update all of the xml and then re-upload them to the server but that would change the id's of those files and most users use that id to track their submissions.

    Does anyone have any experience with this situation or have any advice? Id like to avoid having to remove all of the projects and re-upload them.

    Thanks

    Thursday, February 17, 2011 3:21 PM

Answers

  • It doesn't make sense for the old files, because they already have filenames that are different than the filename you're trying to assign now.  There is no good way to fix what you've done on the existing files, because they all have improper file names.  Originally, did you really have the concat function in the submit data connection itself instead of referencing a filename field?  If so, then you don't have a way of identifying the fact that those old files are pre-existing.  You need some artifact - some piece of metadata in the old forms - that you can use in your Submit button's comparison statement so that it continues to use the existing filenames for the old files but uses the new method for new filenames.  This would work if you could find some way of detecting that the current file was either before or after the change.  You may have to use add a Form Load rule that checks to see if a KNOWN REQUIRED field is blank when the form is opened, and if the txtFilename is ALSO blank, then you know it's an old form.  You would then set some field (may have to create a new one) to the value of OLD.

    Form Load:

    • If RequiredField is blank AND txtFilename is blank, then set AgeField to OLD

    Submit button:

    • If AgeField is equal to old AND txtFilename is blank, then set txtFilename to concat(ProjectName, userName())

    Then, you would still submit with the new data connection configuration that references txtFilename.  It would still be saving as the old name, and it would only perform the FormLoad step the first time an old file is re-submitted.  The major downside is knowing the proper username to put in the filename, because it may not be the person who is updating it.  Hopefully, you stored the original username in the form somewhere.

    The only sure way to do this is to leave the original template alone and add the new template as a content type so that only the new ones would get this new field and new submit method.  HOWEVER, you need to make sure you don't duplicate the promoted fields.  You would need to re-map each field so that it maps to existing fields from the original template.

    Be sure that anything you try is TESTED in a separate environment.


    SharePoint Architect || Microsoft MVP || My Blog
    Planet Technologies || SharePoint Task Force
    • Marked as answer by Leoyi Sun Friday, February 25, 2011 1:42 AM
    Sunday, February 20, 2011 9:11 AM

All replies

  • So now i need to fix it and the way i found was to use a hidden filename field and determine if the form was new or not, use a timestamp, etc. So i added this txtFilename field and changed the File name field in the Submit DC to use that field instead of the concat(projectname, userid).

    Any new projects work completely fine and the way they should, but any projects that were in the system before this update (about 3800 of them) all fail on submit and give the generic "The form cannot be submitted because of an error" message.

    How are you checking, if the form is new or not? I'm not sure if this is how you are doing it, but make that "txtFileName" field as required. And use a rule when the form opens. It should have a condition to check if this field is blank. If it is, then put in timestamp value.

    Also, I'm not sure, but I *think*, you may also need to relink your old forms. Select the "Relink Documents" option from the view menu in form library. Then choose the old forms and click on "Relink" button.

    Test this out on a test library.

     


    Pman
    http://www.pmansLab.com/
    Saturday, February 19, 2011 5:04 PM
  • It doesn't make sense for the old files, because they already have filenames that are different than the filename you're trying to assign now.  There is no good way to fix what you've done on the existing files, because they all have improper file names.  Originally, did you really have the concat function in the submit data connection itself instead of referencing a filename field?  If so, then you don't have a way of identifying the fact that those old files are pre-existing.  You need some artifact - some piece of metadata in the old forms - that you can use in your Submit button's comparison statement so that it continues to use the existing filenames for the old files but uses the new method for new filenames.  This would work if you could find some way of detecting that the current file was either before or after the change.  You may have to use add a Form Load rule that checks to see if a KNOWN REQUIRED field is blank when the form is opened, and if the txtFilename is ALSO blank, then you know it's an old form.  You would then set some field (may have to create a new one) to the value of OLD.

    Form Load:

    • If RequiredField is blank AND txtFilename is blank, then set AgeField to OLD

    Submit button:

    • If AgeField is equal to old AND txtFilename is blank, then set txtFilename to concat(ProjectName, userName())

    Then, you would still submit with the new data connection configuration that references txtFilename.  It would still be saving as the old name, and it would only perform the FormLoad step the first time an old file is re-submitted.  The major downside is knowing the proper username to put in the filename, because it may not be the person who is updating it.  Hopefully, you stored the original username in the form somewhere.

    The only sure way to do this is to leave the original template alone and add the new template as a content type so that only the new ones would get this new field and new submit method.  HOWEVER, you need to make sure you don't duplicate the promoted fields.  You would need to re-map each field so that it maps to existing fields from the original template.

    Be sure that anything you try is TESTED in a separate environment.


    SharePoint Architect || Microsoft MVP || My Blog
    Planet Technologies || SharePoint Task Force
    • Marked as answer by Leoyi Sun Friday, February 25, 2011 1:42 AM
    Sunday, February 20, 2011 9:11 AM