Save and Save As default to form name? - InfoPath Dev
in

InfoPath Dev

Save and Save As default to form name?

Last post 05-14-2008 05:57 AM by ehaze. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 05-13-2008 11:59 AM

    • ehaze
    • Top 500 Contributor
    • Joined on 12-11-2007
    • Posts 49

    Save and Save As default to form name?

    Is there somewhere in infopath that i can change the name that appears when the user saves a form?

     

     

  • 05-13-2008 09:47 PM In reply to

    Re: Save and Save As default to form name?

    Best practice is to use a submit data connection so that the file name is standardized and cannot be changed by the user.

    You can then create a dynamic file name from fields in the form.

  • 05-14-2008 05:57 AM In reply to

    • ehaze
    • Top 500 Contributor
    • Joined on 12-11-2007
    • Posts 49

    Re: Save and Save As default to form name?

    Found it.

     

    public void FormEvents_Save(object sender, SaveEventArgs e)
    {
        string userPrincipalName = MainDataSource.CreateNavigator().SelectSingleNode("//my:userPrincipalName", NamespaceManager).InnerXml;
        string projectName = MainDataSource.CreateNavigator().SelectSingleNode("//my:project", NamespaceManager).InnerXml;
        string startDate = MainDataSource.CreateNavigator().SelectSingleNode("//my:startDate", NamespaceManager).InnerXml;
        if (this.New || e.IsSaveAs == false)
        {
            if (e.IsSaveAs)
            {
                this.SetSaveAsDialogLocation(@"c:\temp");
                this.SetSaveAsDialogFilename(userPrincipalName + "_" + projectName + "_" + startDate);
            }
            e.CancelableArgs.Cancel = false;
            e.PerformSaveOperation();
        }
        else
        {
            e.CancelableArgs.Message = "This functionality has been disabled.";
            e.CancelableArgs.MessageDetails = "Only new forms can use the 'Save As' functionality.";
        }
    }

    VB:

            Public Sub FormEvents_Save(ByVal sender As Object, ByVal e As SaveEventArgs)

                If Me.[New] OrElse e.IsSaveAs = False Then
                    If e.IsSaveAs Then
                        Me.SetSaveAsDialogLocation("c:\temp")
                        Me.SetSaveAsDialogFilename("TESTING")
                    End If
                    e.CancelableArgs.Cancel = False
                    e.PerformSaveOperation()
                Else
                    e.CancelableArgs.Message = "This functionality has been disabled."
                    e.CancelableArgs.MessageDetails = "Only new forms can use the 'Save As' functionality."
                End If

            End Sub

     

    credit goes to this blog:

    http://blogs.3sharp.com/davidg/Default.aspx 

     

     

    Filed under: , , ,
Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.