Save as equal to field-name - InfoPath Dev
in

InfoPath Dev

Save as equal to field-name

Last post 09-30-2010 05:32 AM by GazM. 11 replies.
Page 1 of 1 (12 items)
Sort Posts: Previous Next
  • 09-20-2010 01:38 AM

    Save as equal to field-name

    Hello everybody

    Infopath is absolutetly new for me and I have a probably simple question (and sorry for that):

    I created a new form with a save-button. Now I want that when somebody saves the form, the file-name is equal to a field-name.

    Can somebody help me with that?

    Thx in advance.

    Regards,
    Marcel

  • 09-20-2010 07:34 AM In reply to

    Re: Save as equal to field-name

    Hello,

    When you create the data connection to submit to SharePoint you will be asked to provide the name for the form. In that screen, you can select a field from your form. Step by step at this link.

    Good luck!

    Ernesto Machado
    Qdabra® Software/ InfoPathDev.com
    The InfoPath Experts – Streamline data gathering to turn process into knowledge.™


  • 09-20-2010 07:40 AM In reply to

    Re: Save as equal to field-name

    Hi Ernesto

    How to save and publish the form is clear for me. But after in the Sharepoint if somebody from the company clicks on "new", fill out the form and he saves at the end, I want that the file-name is equal to a field. Is that possible?

    Thx a lot for your help.

     Cheers,

    Marcel

  • 09-20-2010 07:46 AM In reply to

    Re: Save as equal to field-name

    Hi Marcel,

    So, to be clear, the question concerns Save / Save As, and not submitting via a data connection, is that correct?

    Ernesto Machado
    Qdabra® Software/ InfoPathDev.com
    The InfoPath Experts – Streamline data gathering to turn process into knowledge.™


  • 09-20-2010 07:52 AM In reply to

    Re: Save as equal to field-name

    Exactly, somebody clicks on save and it takes the file-name from a field...

  • 09-20-2010 08:50 AM In reply to

    Re: Save as equal to field-name

    I don't think this is possible out of the box. You might be able to accomplish it writing your own custom code. For example, using qRules we can suggest a filename and filepath for Save and Save As, but this is just a suggestion and the user can overwrite it.

    Ernesto Machado
    Qdabra® Software/ InfoPathDev.com
    The InfoPath Experts – Streamline data gathering to turn process into knowledge.™


  • 09-23-2010 03:24 AM In reply to

    Re: Save as equal to field-name

    I wrote this code:

                Dim PositionName As String
                Dim InnovationUnit As String
                Dim SaveFile As String
                PositionName = value_fied108
                InnovationUnit = value_fied109
                SaveFile = PositionName & InnovationUnit
                SaveAs(SaveFile)

     Everything is working, but I don't how to fill PostionName & InnovationUnit with the values from the fields in Infopath...any idea?

  • 09-24-2010 12:29 AM In reply to

    Re: Save as equal to field-name

     Hi, try to replace

    PositionName = value_fied108
    InnovationUnit = value_fied109

    by 

    PositionName = thisXDocument.DOM.selectSingleNode("XPATH").text

    InnovationUnit = thisXDocument.DOM.selectSingleNode("XPATH").text

    Xpath is the path of your field you have to replace XPATH by your xml xpath value, to copy it, Right click on your field on the datasource and select copy xpath.

     

  • 09-24-2010 01:03 AM In reply to

    Re: Save as equal to field-name

    Hi & thx for help!

    I just inserted your code and I got the message--> Name 'thisXDocument' is not declared, any idea? I think this is the last think I need to know....

     

    Dim PositionName As String
    Dim InnovationUnit As String
    Dim SaveFile As String
    PositionName = thisXDocument.DOM.selectSingleNode("CTRL166").text
    InnovationUnit = thisXDocument.DOM.selectSingleNode(
    "CTRL167").text
    SaveFile = PositionName & InnovationUnit
    SaveAs(SaveFile)

  • 09-24-2010 05:36 AM In reply to

    Re: Save as equal to field-name

    Ok you probably use vb2007 try

    MainDataSource.CreateNavigator().SelectSingleNode("xpath", NamespaceManager).Value

    I notice that your xpath is probably bad it must look like something like :/my:myFields/my:Field1

  • 09-30-2010 12:32 AM In reply to

    Re: Save as equal to field-name

    Hi Potenkim

    First of all thx for your great help!

    I tried to insert this code like you told me:

    Dim PositionName As String
    Dim InnovationUnit As String
    Dim SaveFile As String
    PositionName = MainDataSource.CreateNavigator().SelectSingleNode(":/my:myFields/my:Field108", NamespaceManager).Value>
    InnovationUnit = MainDataSource.CreateNavigator().SelectSingleNode(
    ":/my:myFields/my:Field109", NamespaceManager).Value
    SaveFile = PositionName & InnovationUnit
    SaveAs(SaveFile)

    --> I got an error message-->  ':/my:myFields/my:Field108' has an invalid token.

     

    Details of error:

    System.Xml.XPath.XPathException was unhandled by user code
      Message="':/my:myFields/my:Field108' has an invalid token."
      Source="System.Xml"
      StackTrace:
           at MS.Internal.Xml.XPath.XPathScanner.NextLex()
           at MS.Internal.Xml.XPath.XPathScanner..ctor(String xpathExpr)
           at MS.Internal.Xml.XPath.XPathParser.ParseXPathExpresion(String xpathExpresion)
           at MS.Internal.Xml.XPath.QueryBuilder.Build(String query, Boolean allowVar, Boolean allowKey)
           at MS.Internal.Xml.XPath.QueryBuilder.Build(String query, Boolean& needContext)
           at System.Xml.XPath.XPathExpression.Compile(String xpath, IXmlNamespaceResolver nsResolver)
           at System.Xml.XPath.XPathNavigator.SelectSingleNode(String xpath, IXmlNamespaceResolver resolver)
           at _20100916_Competency_Catalogue.FormCode.CTRL195_5_Clicked(Object sender, ClickedEventArgs e)
           at Microsoft.Office.InfoPath.Internal.ButtonEventHost.OnButtonClick(DocActionEvent pEvent)
           at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)

     

    Incredible ;) any idea...?

  • 09-30-2010 05:32 AM In reply to

    • GazM
    • Top 200 Contributor
      Male
    • Joined on 11-09-2005
    • England
    • Posts 54

    Re: Save as equal to field-name

     Hi

    You could try this code with an OnSaveRequest - Tools, Form Options, Open and Save, Save using custom code - it works for me and you may be able to adapt it for your button.

     Sub XDocument_OnSaveRequest(eventObj)

    Dim PositionName

    Dim InnovationUnit

    Dim SaveFile

    PositionName = XDocument.DOM.selectSingleNode("//my:myFields/my:field108").text

    InnovationUnit = XDocument.DOM.selectSingleNode("//my:myFields/my:field109").text

    SaveFile = PositionName & InnovationUnit

    If XDocument.IsNew = True or eventObj.IsSaveAs = False then

    If eventObj.IsSaveAs = True then

    XDocument.UI.SetSaveAsDialogFileName(SaveFile)

    End If

    eventObj.IsCancelled = eventObj.PerformSaveOperation

    eventObj.ReturnStatus = True

    Else XDocument.UI.Alert("The 'Save As' function is disabled for existing forms.")

    End If

    End Sub

     

    Gary

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