Customize the Document File Name when Submitting an InfoPath form to SharePoint

Applies To

Objective

To provide instructions for customizing the document file name when submitting an InfoPath form to SharePoint.

Summary

After enabling the Submit button, you can customize the naming convention of the form by modifying the AgilePointSumbitAndClose() function using the built in Microsoft Script Editor in InfoPath.

Resolution

  1. To enable the toolbar Submit button on your InfoPath form, in InfoPath, select Tools > Submitting Forms.
  2. Set the values as follows:
  3. Open the script editor by selecting Tools > Programming > Microsoft Script Editor.

    The script that is executed when the Submit button is selected is:

    function XDocument::OnSubmitRequest(eventObj)
    {
                try
                {
                    eventObj.ReturnStatus = true;
                    AgilePointSubmitAndClose();     
                }
                catch(e)
                {
                   eventObj.ReturnStatus = false;
                }
    }
  4. Find the AgilePointSumbitAndClose() function. You will see the line of code that calls CreateInfoPathForm:
    CreateInfoPathForm("","","");

    The CreateInfoPathForm function definition is:

    CreateInfoPathForm(strFileNamePrefix, strDateFormat, strNumberFormat)

    You can see that this function is being called with empty strings as parameter values. This will use the default file name format.

    If you want to specify your own format, pass your own values to this function.

    For example, if you want the file name prefix to be determined by the value of a data element on the form, you can call the function like this:

    var docPrefix = XDocument.DOM.selectSingleNode
    "/my:myFields/my:myDataField").text;
    CreateInfoPathForm(docPrefix,"","");