Want to SUBMIT form with the contents of 2 fields from the form. - InfoPath Dev
in

InfoPath Dev

Want to SUBMIT form with the contents of 2 fields from the form.

Last post 06-23-2008 11:38 AM by barmatt80. 9 replies.
Page 1 of 1 (10 items)
Sort Posts: Previous Next
  • 06-23-2008 08:16 AM

    Want to SUBMIT form with the contents of 2 fields from the form.

    Seems simple, I just can't quite get the syntax right. One field is a drop down, the other is a date.

    Field 1:   AA

    Field 2:    06/23/2008 - or whatever format dates are stored

    AA20080623.xml is pretty much what I would like the final name to be...something like that.

    I've tried: office.date by adding the fields and office&date as well as others.

  • 06-23-2008 08:44 AM In reply to

    Re: Want to SUBMIT form with the contents of 2 fields from the form.

    My first question is why use code?  I ask because this can all be accomplished using some simple rules within infopath.

     Also the incrementing number would have to be saved in a list or database field.  A new form would be opened, query that field, add 1 to it, then save it back.  I just did that in an access database but saved the number as an integer, and then did format(FIELD, "00000") to get the correct format for use in the filename.

     I don't know javascript, but I might be able to find some in vb.net

     

  • 06-23-2008 08:50 AM In reply to

    Re: Want to SUBMIT form with the contents of 2 fields from the form.

    Cheers barmatt80,

    I am trying to simply do it without code, I'm in the Data Connection Wizard, and am adding a "submit data" connection. It's being submitted to a SharePoint library (that works). I am trying to populate the File Name field with some contents that the user fills out in the form.

    I can successfully insert ONE FIELD but what I want is to include 2 fields, and that's where I get the error.

    Ex: I click on the Fx box, and it'll pull the field names and underline them- just won't validate.

  • 06-23-2008 09:03 AM In reply to

    Re: Want to SUBMIT form with the contents of 2 fields from the form.

    How I usually handle this is using a hidden field on the form to concat all the information I want and then add that single field to the file name in the data connection.

     Ex. Text box named FileName.  On the submit button I would put a rule that said if this field is not blank, then set FileName to this value. Something like concat(Field1, Field2).  Then my next step in my submit button would be the actual submit to sharepoint on if FileName was not blank.

  • 06-23-2008 09:12 AM In reply to

    Re: Want to SUBMIT form with the contents of 2 fields from the form.

    Great idea! Thanks! Doing this helped me figure out what I needed:

    I clicked the Fx button:

    concat(office,reportDate) 

    I guess I was trying to do this from the wrong place before. The hidden field trick will come in handy too, I am sure.
     

  • 06-23-2008 09:31 AM In reply to

    Re: Want to SUBMIT form with the contents of 2 fields from the form.

    Hello:

    You can do this using the concat function to concatenate your fields (along with the .xml extension) and translate to remove the dashes from the date. Select the Insert Formula button next to the text box for the name. In the Insert Formula window, select Insert Function. From the available Text functions, select concat. The first field would be your office field. After the comma, select Insert Function again, and this time select translate from the available Text functions. The translate function takes three arguments. First is the field you wish to translate (in your case, the date field). Second is the string you wish to translate (here it is the "-"). And, finally, the replacement string. We want to replace the dashes with nothing, so we use blank quotes. After another comma, add the file extension. Your finished formula will look like this:

    concat(office, translate(date, "-", ""), ".xml")

    And the result should be the file name format you were looking for.

    Hilary Stoupa

    Filed under:
  • 06-23-2008 09:33 AM In reply to

    Re: Want to SUBMIT form with the contents of 2 fields from the form.

    Whoops! I see I was a bit late to the party! :)

    Hilary Stoupa

  • 06-23-2008 09:49 AM In reply to

    Re: Want to SUBMIT form with the contents of 2 fields from the form.

    No no, that was a very helpful tip as well!! Thanks! Now, is there a way through data validation that I can force people to use a date that is a certain day of the week (friday)? 

  • 06-23-2008 10:07 AM In reply to

    Re: Want to SUBMIT form with the contents of 2 fields from the form.

    I can't think of a way to do that with data validation -- even if you format the field to display the day of the week the value of the field will be the date. It could be done with code, of course, if you are not adverse to that approach.

    Hilary Stoupa

  • 06-23-2008 11:38 AM In reply to

    Re: Want to SUBMIT form with the contents of 2 fields from the form.

    there is a way to ensure that they use it, but I did it via code, not by rules.

     I had a date picker that would check the day of the week, and that returned an integer.  That integer is zero based, meaning 0 corresponds to Sunday.  I am sure 0 would correspond to Sunday in the US time, not sure about other countries.  Then I used a case statement to check it as Saturday(my day of the week needed).  Then assign the text name of the day to text box.  Then in rules I put a rule that said if the text was not equal to Saturday, then show message adn reset all fields. 

    Here it is in vb that is backward compatible with infopath 2003.

    If thisXDocument.DOM.selectSingleNode("/dfs:myFields/my:Week/my:WeekBeginning").text <> "" Then

    Dim strDate As String = thisXDocument.DOM.selectSingleNode("/dfs:myFields/my:Week/my:WeekBeginning").textDim dt As New DateTime

    dt = DateTime.Parse(strDate)

    Dim strDayID As String = dt.DayOfWeek

    Dim strDayofWeek As String

    Select Case strDayID

    Case 0

    strDayofWeek = "Sunday"

    Case 1

    strDayofWeek = "Monday"

    Case 2

    strDayofWeek = "Tuesday"

    Case 3

    strDayofWeek = "Wednesday"

    Case 4

    strDayofWeek = "Thursday"

    Case 5

    strDayofWeek = "Friday"

    Case 6

    strDayofWeek = "Saturday"

    Case Else

    strDayofWeek = "Sunday"

    End Select

    thisXDocument.DOM.selectSingleNode("/dfs:myFields/my:DayyOfweek").text = strDayofWeek

    End If

     

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