Get the documentID - InfoPath Dev
in

InfoPath Dev

Get the documentID

Last post 04-11-2012 04:59 PM by Jay@Work. 16 replies.
Page 1 of 2 (17 items) 1 2 Next >
Sort Posts: Previous Next
  • 04-10-2012 02:31 PM

    Get the documentID

    If such a thing exist and can be accessed by infopath?

    With a Sp list I can use the item ID for certain things.
    In my forms library I would like to get the document (?) ID and use this to name the xml file so I get a sequential numbering system in my library.
    Do document libraries have IDs like lists do and how can I grab this value on submit of my form?

    Browser based form. SP 2010. Infopath 2010

    Thanks

  • 04-10-2012 02:37 PM In reply to

    I'm not sure if you can do that.. Document ID's get assigned when the item is uploaded to the library.. at which point it would have to have a file name already.. unless you can somehow automatically change the file name to the Document ID after it's been submitted.
  • 04-10-2012 02:43 PM In reply to

    The library also has columns so that people can view/edit properties on any given row so it appears to be a list in every way except that the main content is a form.

    Would there be a list ID associated with this library that I could use?

  • 04-10-2012 02:53 PM In reply to

    There is an id - but the issue is getting it before your file is submitted, since you say you want to use it for your file name. It is generated when the file is added to the library. You can query the library and get back all the current IDs and increment the max by one and hope that no one submits a different form before the form you are currently submitting is saved.

    Hilary Stoupa

  • 04-11-2012 01:21 PM In reply to

    ok plan B
    I have created a data connection that gets the max ID from the list on submit and adds 1 to it and names the doc with this.
    This is good as it should reduce the chance of 2 people saving at the same time and having the same max()

    Problem is that the naming convention is OPxx.xml where xx is the sequential number.
    So "OP" + max(id) +1 results in NaN.xml which is what I would expect.

    There seems to be very limited functions when using browser forms - normally I would use a combo of left() and length() to get rid of the "OP" and then put it back afterwards.

    Any ideas?

  • 04-11-2012 02:07 PM In reply to

    You need to use a concat formula:

    concat("OP", max(id) + 1)

    Hilary Stoupa

  • 04-11-2012 02:33 PM In reply to

    Now I get OPNaN.xml

    The problem is (or at least this is the problem in other programming) that OP01 is being treated like a string.
    Somehow I need to say, extract the number portion from the string, add 1 to this number and then put the OP back on and use this as the form name.
    Simple with a full range of string functions to work with but I don't see them in the formula builder

  • 04-11-2012 02:38 PM In reply to

    I see, you are getting back a string - I'd thought you were returning the actual list item ID, which is a number.

    You could use translate to get rid of the OP:

    translate(id, "OP", "")

    Hilary Stoupa

  • 04-11-2012 03:06 PM In reply to

    Thanks so how do I string (so to speak) that all together.
    Say the last used doc name is OP01.xml, I need to save the next as OP02.xml

     

  • 04-11-2012 03:55 PM In reply to

    You might be getting NaN because there are no documents in the library, and therefore Max(ID) returns NaN. Upload a dummy/blank document to get ID =1 then you should be okay. Once there is another document in there, you can delete the blank document.
  • 04-11-2012 04:09 PM In reply to

    Well, the zero padding is also going to be a challenge.

    When do you plan to zero pad? Only if the number is a single digit?

     

    Hilary Stoupa

  • 04-11-2012 04:28 PM In reply to

    I have created an intial doc to ensure we have a max(ID), the doc currently in the library is OP01.xml
    Letter O, letter P, zero, one
  • 04-11-2012 04:34 PM In reply to

    Not sure what my reasoning behind the 01 was, can just as easily be 1 - making the doc name OP1.xml
    Will give that a go now.....

    ...

    Same deal - renamed the existing doc to OP1.xml and the next file becomes OPNaN.xml

    I just had a thought, given that I am retrieving the ID and not the filename of the doc, why am I messing with OP?
    Rhetorical.
    I think I need another coffee.
    I need to retreive the ID add 1 to it, then prefix it wil OP and make this the filename. For some reason I have been working as though the ID was prefixed with OP.

    Will report back

  • 04-11-2012 04:36 PM In reply to

    Coffee helps with InfoPath. :-)

    If you are retrieving the ID, the initial concat should work. But add a calculated value to your form that shows the max ID from your secondary data source - make sure that is returning what you'd expect. Then you can troubleshoot from there.

    Hilary Stoupa

  • 04-11-2012 04:45 PM In reply to

    ok mystery solved! The data connection that was getting max(id) wasn't getting the value when the form was loaded so my *guess* is that it didn't have a value to use when naming the form.
    This is unfortunate as I was hoping to not get this value until submit as there could be a clash if 2 people create a new doc at similar times (much less likely to clash if retrieving the ID on submit)
    Can I get the value at submit or must I "carry" it with me as the form is being filled out?

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