save form with concat filename, but don't create a new form... - InfoPath Dev
in

InfoPath Dev

save form with concat filename, but don't create a new form...

Last post 12-31-2008 02:56 AM by kalaicompute. 17 replies.
Page 1 of 2 (18 items) 1 2 Next >
Sort Posts: Previous Next
  • 12-16-2008 03:48 AM

    save form with concat filename, but don't create a new form...

    I have a browser based form. I want to use a default filename (concat some fields) so the user won't have to fill it in. That won't be a problem. But... I want to use it with a save button, instead of submit. (Or submit without creating a new form.) In Visual Studio C# I didn't found the save method when the form is browser enabled. Does anybody have an idea?
  • 12-16-2008 04:01 AM In reply to

    Re: save form with concat filename, but don't create a new form...

    Hi and welcome to forums,

    You can place a button in the design and give the label name as ‘Save'. Select the Action as Submit and add a submit connection. While adding the submit connection make sure to check the ‘Allow overwrite if file exists' check box.

     

     

    Swathip
    www.ggktech.com
  • 12-16-2008 08:26 PM In reply to

    Re: save form with concat filename, but don't create a new form...

    Do you mean you don't want it to create a new form the first time and save it in limbo somewhere?  You can't do that.  If you mean that after the first time it is saved/submitted that all successive "submits" done by a button overwrite the previous one instead of creating a new XML form, then do what the other poster said.  Make a custom button that simply has rules behind it (don't have to use submit at all) and have a secondary data connection that submits it to the library directly with the same filename you specified the first time.

  • 12-17-2008 12:24 AM In reply to

    Re: save form with concat filename, but don't create a new form...

     Thanks’ for the quick response! I thought I needed to code for this solution... But it’s as simple as you wrote.
    I've tried it like you said, but it seems to be a problem with the concat* function. So it’s still not working as I want.
    I want to make a filename like “test_<id>” where <id> is the unique ID of the form**.
    When creating a new XML the <id> is not known so “test_.xml” will be created. (that’s not correct***)
    After that when editing “test_.xml” the <id> is known (let’s say 11) so the file will be saved as “test_11.xml”. Seems to be ok…
    When editing “test_11.xml” strangely it will submit as “test_12.xml” even tough ‘Overwrite when file exists’ is “on” at the submit data connection.
    * Concat(“test_”; @ID)
    ** @ID comes from a data connection to get the unique ID.
    *** We can solve this to guess the ID by searching for the highest number and add 1. But what will happen when two users create a form at the same time?

  • 12-17-2008 07:46 AM In reply to

    Re: save form with concat filename, but don't create a new form...

    You can't use the ID in that case - you'll just need to use something else.  I use the now() function in the concatenated filename so that all are unique.

    The reason why this is happening to use is because the original filename is Test_, but the second time you submit it, it changes to Test_11.  Those are different filenames, so it cannot overwrite and treats it as a new filename.  I would just ignore the ID, and if you truly need a unique ID # like that, then assign it in the form somewhere.  Also, create a "filename" data field in your form, create a rule on your submit button that sets the filename ONLY on the first submit, then in your data connection that submits to the library, tell it to use the value in the field named "filename."  This way, you set the filename once - when originally submitted - and it never changes.  That way you know your filename will be correct each time.  You don't want to keep creating the filename on each submit.  It requires to separate rules on your submit button in reverse order with the first one only firing if filename is not blank.

  • 12-17-2008 08:35 AM In reply to

    Re: save form with concat filename, but don't create a new form...

    Thank you, It works!

    So the only way is 'guess the ID' and hope no one uses the same ID "OR" work with dates...

    But I think it could be a problem when two users press submit in the same second... Since now() is year-month-dayThour-minute-second...

     

     

  • 12-17-2008 08:51 AM In reply to

    Re: save form with concat filename, but don't create a new form...

    No, you don't have to guess or hope.  You can have a different data field with your own unique ID generator if you think the now() function isn't going to be unique enough.  I always include the current username AND the now() function, because then it doesn't matter if two people submit at the same time, because it will still always be a unique filename.  One person can't submit two at the same exact millisecond, especially if you have yet another piece of info from the form that makes it even more unique.  I think this will work for you...

  • 12-17-2008 12:37 PM In reply to

    Re: save form with concat filename, but don't create a new form...

    I have set up a form where I am using the @ID for the sequential form number BUT I am concerned about duplication.  Is there a way to concat filename with @id .. please provide the actual formula to put in the Expression Box?

     

  • 12-17-2008 12:52 PM In reply to

    Re: save form with concat filename, but don't create a new form...

    I'm not sure you can rely on ID, because the ID is not assigned until AFTER you first submit it to the library.  However, you can't worry about duplication, because the ID field of every SharePoint list is a unique identifier.  The numbers are sequential and are never duplicated.

    Yes, you can concatenate any field with anything else, but again, ID will not be available until AFTER the form has been submitted once.  Also, there is no filename until you have submitted it, so neither of these are a good idea, imo.  To use these, you would have to setup a rule on your submit button or submit action that first submits the form to the library without closing it, goes out and retrieves the ID and filename, then concatenates those two, then places that string into some other field, then re-submits the form again using the same filename, and then closes.  Is that what you want to do?  If you let me know what you'd like to accomplish, I might be able to give you a solution.

    Here is the syntax logically:

    concat(ID, Name)

    Pretty simple.  The reason they are underlined is because that's how they will look when you choose Insert Function > concat and then see "double click to insert field."  When you double click to insert field, you will then go to your data connection that pulls the ID and filename from the library and choose those inside the concat parentheses separated by a comma.

    My preference is to dynamically create the filename for the user without them having to use the Save function or the built-in submit function.  I take their username and concatenate it with the date/time stamp using now().  The syntax is concat(userName(),"-",now()).  I set a field named "filename" to th at expression and then use that filename in my SharePoint Library Submit data connection so that it will never change and is easy to reference.

  • 12-17-2008 11:53 PM In reply to

    Re: save form with concat filename, but don't create a new form...

    warrtalon, your solution ‘username & date’ is unique enough. I will use that. Thank you very much!

    What I wanted was a file name with ID_field1_field2. (Where ID is the unique ID from a sharepoint library) But that’s not possible; because ID is not yet available in a new form. And the work around: First save/submit to generate ID will never work because the file is saved with a filename without ID (because it wasn’t available) so you will never be able to overwrite it! (It will generate a new ID instead…) Correct me if I’m wrong but I think that’s how it works…

  • 12-18-2008 05:25 AM In reply to

    Re: save form with concat filename, but don't create a new form...

    No - username + date is not unique enough as one user could enter many orders in one day.

     Any other ideas?

  • 12-18-2008 07:05 AM In reply to

    Re: save form with concat filename, but don't create a new form...

    You are right, but when I use the date function "now()" I get 2008-12-18T15-55-50. That means a user must make more than one form per second... So for me that's unique enough...
    Have you tried the function now() ? Does it return only a date (2008-12-18)??


  • 12-18-2008 07:28 AM In reply to

    Re: save form with concat filename, but don't create a new form...

    Gayle, it's not date, but date/time.  Today() does today's date, but now() does the time stamp down to the second.  The same user would have to submit two forms in the same millisecond.

  • 12-18-2008 07:42 AM In reply to

    Re: save form with concat filename, but don't create a new form...

     warrtalon, you say millisecond but it's second isn't it?

  • 12-18-2008 07:47 AM In reply to

    Re: save form with concat filename, but don't create a new form...

    Not necessarily, since they can do two within a second of each other and have different time stamps.  You can say centisecond if you want - millisecond is just the more commonly-used term, though not entirely accurate.

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