jscript unique ID - InfoPath Dev
in

InfoPath Dev

jscript unique ID

Last post 06-01-2011 03:56 AM by Skarn. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 04-27-2011 08:32 PM

    • jaekou
    • Not Ranked
    • Joined on 10-26-2010
    • Posts 6

    jscript unique ID

    Hello!  I created an electronic sign-in sheet with InfoPath and an e-sig lcd tablet.  Using jscript code provided by the e-sig tablet vendor I was able to create a jpg of the signature and link it to the document.  The problem I'm having now, because the file name is hardcoded into the control (C:\SigImage.jpg), is that the most current SigImage.jpg is being referenced to all the signed documents.  

    Is there a way in jscript to generate an unique ID using something similar to a now() to give each jpg it's own unique file name to link back to the form?  Here is the code behind my button:

    function CTRL1_5::OnClick(eventObj)

    {

    //This button initiates the tablet for signing 

    sigObj.InitSigPlus();

    sigObj.OpaqueMode=true;

    sigObj.TabletState=1;

    }

    function CTRL2_5::OnClick(eventObj)

    {

    //This button is pressed after the tablet is signed, it attaches the image of the jpg to the InfoPath document

    sigObj.TabletState=0;

    sigObj.ImageFileFormat=4;

    sigObj.ImageXSize=200;

    sigObj.ImageYSize=30;

    sigObj.ImagePenWidth=11;

    sigObj.JustifyMode=5;

    sigObj.WriteImageFile("C:\\SigImage.JPG");

    var objField1 = XDocument.DOM.selectSingleNode("//my:myFields/my:field1");

    objField1.text = "C:\\sigimage.jpg";

    }

    If I could somehow generate an unique ID and pass it as a variable to the WriteImageFile() function and associate it back to objField1.text then I think it might work.  I would greatly appreciate any insight, suggestions, advice anybody can spare!

    Thanks!

    Jimmy

     

     

     

  • 06-01-2011 03:56 AM In reply to

    • Skarn
    • Top 50 Contributor
      Male
    • Joined on 04-20-2008
    • Australia
    • Posts 198

    Using a sig tablet (have no experience) but maybe the sigTablet itself has a uniqueId you can retrieve from the attached device which you could use as the 'prefix identifier' in my suggestion below.

    I usually end up going for a datetime stamp and prefixed with some other identifier, like the current logged in userId.

    Other ideas I've seen on this forum have been using a central SQL server, or web service to send a uniqueId value to the form on open/submit/save.

    When using date-time stamp I remove the extraneous chars (using xpath translate function) e.g. 2011-05-30T13:10:55 becomes 20110530131055. There is risk of someone else generating the exact same time stamp though which is why I prefix with the other identifier.

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