Random ID - InfoPath Dev
in

InfoPath Dev

Random ID

Last post 08-22-2006 03:59 PM by Greg Collins. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 08-21-2006 01:18 AM

    Random ID

    i try to generate random ID :

    how can i write in jscript?

    my code is :

    function ID(GUID) {
    var productNodes = XDocument.DOM.selectNodes("/dfs:myFields/tns:dataFields/tns:XUmmeldProcessRequest/tns:DocumentPrefs");
    productNode.XDocument.DOM.selectSingleNode("tns:GUID").text = Math.random()*1000;
    }

    and it was not work..

    thanks for help......

  • 08-21-2006 06:12 AM In reply to

    • Mahitha
    • Top 200 Contributor
    • Joined on 05-24-2005
    • India
    • Posts 57
    http://infopathdev.com/forums/topic.asp?TOPIC_ID=448

    Hope this helps
  • 08-21-2006 08:45 AM In reply to

    function XDocument::OnLoad(eventObj){

    XDocument.DOM.setProperty("SelectionNamespaces",'xmlns:dfs="http://fokus.fraunhofer.de/XUmmeld" xmlns:tns="http://fokus.fraunhofer.de/XUmmeld"');

    XDocument.DOM.selectSingleNode("//dfs:myFields/tns:dataFields/tns:XUmmeldProcessRequest/tns:DocumentPrefs/@GUID ").text=Math.random()*1000;
    }


    and the error
    XDocument.DOM.selectSingleNode(...)' is null or not an object.
    File:script.js

    <?xml version="1.0" encoding="UTF-8"?><?mso-application progid=" InfoPath.Document"?>
    <?mso-infoPathSolution solutionVersion="1.0.0.83" productVersion="11.0.6565 " PIVersion="1.0.0.0" href=" file:///C:\infopath\Egov_17_08_15_30.xsn" name="urn:schemas-microsoft-com:office:infopath:Egov-17-08-15-30:-dataFormSolution" ?>
    <dfs:myFields xmlns:ns1="http://schemas.microsoft.com/office/infopath/2003/myXSD/2006-08-07T12:43:33 "
    xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"
    xmlns:tns="http://fokus.fraunhofer.de/XUmmeld " xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2006-08-14T12:58:44 " xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" xml:lang="de">
    <dfs:dataFields>
    <tns:XUmmeldProcessRequest>
    <tns:DocumentPrefs>
    <tns:GUID></tns:GUID>
    </tns:DocumentPrefs>
    <tns:CivilServantData>
    <tns:Approval>1</tns:Approval>
    <tns:Comment>1</tns:Comment>
    </tns:CivilServantData>
    .....
    </dfs:dataFields>
    </dfs:myFields>

    can any helps?

    thanks
  • 08-21-2006 11:04 AM In reply to

    The selectSingleNode() is not working because your XPath is incorrect -- specifically, the namespaces are not accurate. Also, GUID is an element and not an attribute.

    Try this:

    XDocument.DOM.selectSingleNode("/dfs:myFields/dfs:dataFields/tns:XUmmeldProcessRequest/tns:DocumentPrefs/tns:GUID").text = Math.random()*1000;
  • 08-22-2006 09:14 AM In reply to

    Thanks Greg, its work

    can i ask again,

    XDocument.DOM.selectSingleNode("/dfs:myFields/dfs:dataFields/tns:XUmmeldProcessRequest/tns:DocumentPrefs/tns:GUID").text = Math.random()*1000;

    from them I have GUI Random : 7017371754586900

    how can i made 7017-3717-5458-6900 ?

    my code is :

    function XDocument::OnLoad(eventObj){

    var Name = XDocument.DOM.selectSingleNode("/dfs:myFields/dfs:dataFields/tns:XUmmeldProcessRequest/tns:RequesterData/tns:RegisteredPersons/tns:RegisteredPerson1/tns:BasicPersonData/tns:Surname").text;
    if (Name == ""){
    id=XDocument.DOM.selectSingleNode("/dfs:myFields/dfs:dataFields/tns:XUmmeldProcessRequest/tns:DocumentPrefs/tns:GUID").text;

    var id=Math.random()*10000;

    var ran_number=Math.round(id);
    uid_string = ran_number.toString() + "-";

    }else {
    XDocument.DOM.selectSingleNode("/dfs:myFields/dfs:dataFields/tns:XUmmeldProcessRequest/tns:DocumentPrefs/tns:GUID").text = Name + Math.random()* 10000 * 10000* 100000 *100000;
    }

    }
    its not work...

    can any help me.. :)

    thanks
  • 08-22-2006 09:44 AM In reply to

    Hallo Greg,

    I have GUI Random : 70173717545822

    how can i made 70173-37173-54583 ?

    mycode is :

    var uid_string;
    var idTesting = Math.random()* 100000;
    var idRound = Math.round(idTesting);
    uid_string = idRound.toString() + " - ";

    var idTesting1 = Math.random()* 100000;
    var idRound1 = Math.round(idTesting1);
    uid_string = idRound1.toString() + " - ";

    var idTesting2 = Math.random()* 100000;
    var idRound2 = Math.round(idTesting2);
    uid_string = idRound2.toString() + " - ";
    XDocument.UI.Alert(idRound2);

    XDocument.DOM.selectSingleNode("/dfs:myFields/dfs:dataFields/tns:XUmmeldProcessRequest/tns:DocumentPrefs/tns:GUID").text= uid_string

    and it show only 54583

    but i want 70173-37173-54583

    thanks for help..

  • 08-22-2006 09:49 AM In reply to

    i got it ..

    uid_string += idRound2.toString() + " - ";
  • 08-22-2006 03:59 PM In reply to

    Great! Glad you were able to figure it out!
    Keep up the good work!
Page 1 of 1 (8 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.