Form ID - InfoPath Dev
in

InfoPath Dev

Form ID

Last post 10-17-2006 12:06 AM by Abhishek. 13 replies.
Page 1 of 1 (14 items)
Sort Posts: Previous Next
  • 04-06-2006 12:39 AM

    Form ID

    Is there something like a form ID which is unique everytime when the user fills out a new form.
    If yes how can I get it.
    Thx
    Listen to Motörhead cos they play Rock'n Roll :)
  • 04-06-2006 01:40 AM In reply to

    Hi Nukkumatti,
    I have a similar situation.What I have done is..
    I use a webservice to accomplish this.
    I have a text file which initially contains "0".When a new form is opened I increment the value in this text file using the web service and return the new value to the form.
    So each time a new form is opened,I have a new Form ID.I call this webservice in the form's onload event.

    regards,
    Abhishek
  • 04-06-2006 04:31 AM In reply to

    Thx Abhishek,
    but code you give me a short code introduction on how to start with it ?

    Thx
    Listen to Motörhead cos they play Rock'n Roll :)
  • 04-06-2006 07:03 AM In reply to

    Ya sure Nukkumatti,
    I will give u the code which I have written.

    [WebMethod]
    public DataSet NextPRSerialNumber()
    {
    String filename = ConfigurationSettings.AppSettings["PRNumFile"];
    System.IO.StreamReader file = new System.IO.StreamReader(filename);
    String strNum = file.ReadToEnd();
    file.Close();

    System.IO.StreamWriter file2 = new System.IO.StreamWriter(filename,false);
    strNum = Convert.ToString(Convert.ToInt32(strNum) + 1);
    file2.WriteLine(strNum);
    file2.Close();
    DataTable dt = new DataTable();
    dt.Columns.Add("PRSerialNumber");
    dt.Rows.Add(new object[]{"PR_" + DateTime.Today.Year + "_" + strNum.PadLeft(6,'0')});
    DataSet ds = new DataSet();
    ds.Tables.Add(dt);
    return ds;
    }


    In ur web.config file,u should have the following...U can change this based on ur text file's location.
    <appSettings>
    <add key="PRNumFile" value="C:\MCG\WebService_PR\PRNum.txt" />
    </appSettings>


    I think u should be able to understand the above code.
    Do the modifications as how u want it.

    Regards,
    Abhishek.
  • 04-06-2006 07:40 AM In reply to

    • maslov
    • Not Ranked
    • Joined on 04-06-2006
    • Russia
    • Posts 2
    Hello, Nukkumatti

    You can also generate unique GUID in Load event using "Scriptlet.TypeLib" ActiveX object (if you are in JavaScript):

    var guid =
    new ActiveXObject("Scriptlet.TypeLib").guid.substring( 0, 38);

    or using System.Guid.NewGuid() method (if you are in .NET).

    Regards,
    Maxim
  • 04-06-2006 10:45 PM In reply to

    Hi Maslov,
    I was just browsing in the net regarding Nukkmatti's point.
    If u want to generate a unique and random formid,what Nukkumatti says is easy to implement and great.
    But if u want a sequential increment of ur form id starting from 0, u can use my method.

    For more on generating random numbers,take a look at the foolowing link.
    http://aspnet.4guysfromrolla.com/articles/101205-1.aspx

    Regards,
    Abhishek
  • 04-06-2006 11:00 PM In reply to

    Thx a LOT you both !
    Listen to Motörhead cos they play Rock'n Roll :)
  • 05-31-2006 11:31 PM In reply to

    • nupur
    • Top 500 Contributor
    • Joined on 05-22-2006
    • Posts 26
    Hi is there some other way to do this using jscript without creating anew web service??????
    thnaks
    Nupur
  • 06-01-2006 03:58 AM In reply to

    Hi Nupur,
    Using the web service is the easiest way I can think of.U can call the web service from ur JScript code.
    Regards,
    Abhishek
  • 06-07-2006 12:54 PM In reply to

    I don't know if you have received a satisfactory answer or not yet to your post, but I can share what I did.

    First, I created a receive data connection attached to my sharepoint forms library. I set it to retrieve the ID field when the form is opened. I then created a text field on my form (this could theoretically be hidden) to set the format. In my case I needed unique form IDs starting at 6000 so my formula to set the field data is 'count(@ID) + 6000'. Every time the form is opened it will do a count of all current forms and add 6000 to it.

    I am sure there are better ways, but I am not a programmer and I think as long as I don't have too many submissions at once I should be ok. Otherwise I guess I will have to code the submit button to pull a current count on submit...no clue how to do that.

    Anyway, hope this helps.
  • 09-15-2006 06:35 AM In reply to

    Since I don't have access to the Sharepoint Web server to install a Web Service, I'm thinking merddyin's solution is a good idea. The problem with implementing it in my situation is that the FormID is not generated until AFTER the form is submitted, so how do you use it as part of the form name when submitting?
  • 09-15-2006 06:38 AM In reply to

    Maxim:

    Can you explain how you use that onload event to generate a unique ID. I'm not a programmer, but can muddle my way through with some guidance.

    Thanks!
  • 10-13-2006 09:51 AM In reply to

    • fillrobs
    • Not Ranked
    • Joined on 10-06-2006
    • United Kingdom
    • Posts 2
    Hi,

    I tried cutting and pasting the below into my asmx file but I get an error on the

    ConfigurationSettings

    It says (when I try and Build the APP)
    "The type or namespace name 'ConfigurationSettings' could not be found (are you missing a using directive or an assembly reference)"

    Any ideas?

    Thanks in advance...

    Phil

    quote:
    Originally posted by Abhishek

    Ya sure Nukkumatti,
    I will give u the code which I have written.

    [WebMethod]
    public DataSet NextPRSerialNumber()
    {
    String filename = ConfigurationSettings.AppSettings["PRNumFile"];
    System.IO.StreamReader file = new System.IO.StreamReader(filename);
    String strNum = file.ReadToEnd();
    file.Close();

    System.IO.StreamWriter file2 = new System.IO.StreamWriter(filename,false);
    strNum = Convert.ToString(Convert.ToInt32(strNum) + 1);
    file2.WriteLine(strNum);
    file2.Close();
    DataTable dt = new DataTable();
    dt.Columns.Add("PRSerialNumber");
    dt.Rows.Add(new object[]{"PR_" + DateTime.Today.Year + "_" + strNum.PadLeft(6,'0')});
    DataSet ds = new DataSet();
    ds.Tables.Add(dt);
    return ds;
    }


    In ur web.config file,u should have the following...U can change this based on ur text file's location.
    <appSettings>
    <add key="PRNumFile" value="C:\MCG\WebService_PR\PRNum.txt" />
    </appSettings>


    I think u should be able to understand the above code.
    Do the modifications as how u want it.

    Regards,
    Abhishek.

  • 10-17-2006 12:06 AM In reply to

    Hi fillrobs,

    U have missed the following namespace System.Configuration
    U need to add this namespace like this...
    using System.Configuration;

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