Generate random ID - InfoPath Dev
in

InfoPath Dev

Generate random ID

Last post 07-10-2006 12:57 PM by fredarwin. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 07-07-2006 03:05 PM

    Generate random ID

    Hello all, I am new to this forum and new to infopath
    I am trying to generate a random number, that will be place into the ID field, everytime I load a form. So what I mean is when I load the form the random number will show into the ID field and the user finally I want the user to not be able to modify this ID field.

    ANy help pleaseeee I really aprecciatte

    Thank you
  • 07-07-2006 09:00 PM In reply to

    Hello
    Welcome to InfopathDev Forums

    You can do this by generating a GUID which will be a unique number
    Try reading the links below
    http://www.infopathdev.com/forums/topic.asp?TOPIC_ID=2431
    http://www.infopathdev.com/forums/topic.asp?TOPIC_ID=448

    Also you can search for more in the forums by typing GUID in the search box above
    Kalyan G Reddy
    Infopath MVP 2007 and 2008
  • 07-10-2006 05:54 AM In reply to

    Maybe, u can use this code:

    var value = Math.random()*1000;

    regards,
  • 07-10-2006 07:25 AM In reply to

    Hello, thank you very much for your help. But where do I put this code? Once I had all my data field in the form I tried to go to Tools>Programming but I cant click in any of those options. Where do I need to write that code, and is just a copy-paste or do I need to write something else?
  • 07-10-2006 07:51 AM In reply to

    Ok, now I can see the programming option. I clicked on On Load Event, then I tried putting different lines of code. The field on my ID is called "ID" (I created a db in Access and add a field for each table name: ID). I then drag and drop all the fields from one of my table to the form, so the ID field is in the form. My question is, how do I write this code, where do I put the "ID" name in the code. Is it like: var ID =
    new ActiveXObject("Scriptlet.TypeLib").guid.substring( 0, 38); or var ID = System.Guid.NewGuid(); ? is that all the code I need to write? I am so confused, sorry for been such a novice. Thank youu
  • 07-10-2006 12:57 PM In reply to

    try this:

    Put a button control, go to properties and edit code, put the next code(jscript):


    XDocument.DOM.selectSingleNode("/myFields/ID").text = Math.random()*1000;
Page 1 of 1 (6 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.