Load Event - Generate GUID - InfoPath Dev
in

InfoPath Dev

Load Event - Generate GUID

Last post 08-02-2006 12:10 PM by Matt Faus. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 07-31-2006 08:42 AM

    • SPP_ACS
    • Not Ranked
    • Joined on 07-31-2006
    • USA
    • Posts 5

    Load Event - Generate GUID

    I am extremely new to Infopath, but learning by making mistakes.

    Here is the code I have so far:
    function XDocument::OnLoad(eventObj)
    {
    XDocument.DOM.selectSingleNode("/myFields/CallAuditID").text = System.Guid.NewGuid()
    }

    Any assitance would be great. I have read up on the forums, but still confused.

    Paul
  • 07-31-2006 10:34 AM In reply to

    Re: Load Event - Generate GUID

    Hi Paul and welcome to the forums! I don't see anything blaringly wrong with this - what error are you getting?
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 07-31-2006 10:38 AM In reply to

    • SPP_ACS
    • Not Ranked
    • Joined on 07-31-2006
    • USA
    • Posts 5

    Re: Load Event - Generate GUID

    quote:
    Originally posted by Matt Faus

    Hi Paul and welcome to the forums! I don't see anything blaringly wrong with this - what error are you getting?



    The Error:
    XDocument.DOM.selectSingleNode( . . . ) is undefined
  • 07-31-2006 03:28 PM In reply to

    • SPP_ACS
    • Not Ranked
    • Joined on 07-31-2006
    • USA
    • Posts 5

    Re: Load Event - Generate GUID

    Additional information on error:
    'XDocument.DOM.selectSingleNode(..)' is null or not an object.
    File:script.js
    Line:77

    Is there another way to generate this GUID field on load or during the submission the the SQL Server.
  • 07-31-2006 09:25 PM In reply to

    • SPP_ACS
    • Not Ranked
    • Joined on 07-31-2006
    • USA
    • Posts 5

    Re: Load Event - Generate GUID

    Just for an update to everyone, I have fixed the undefined system error. The following changes to the namespace:

    //<namespacesDefinition>
    XDocument.DOM.setProperty("SelectionNamespaces", 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:s0="urn:sap-com:document:sap:rfc:functions" xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://schemas.xmlsoap.org/wsdl/" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2004-06-03T02:08:05" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003"');
    //</namespacesDefinition>

    Also, I am using the function to generate the GUID as follows by a click of a button:
    //==================
    // Magic GUID Click
    //==================
    function CTRL53_7::OnClick(eventObj)
    {
    // Create GUID in Call Audit ID Field
    XDocument.DOM.selectSingleNode("/dfs:myFields/dfs:dataFields/d:tblCallAuditStorage/@CallAuditID").text = System.Guid.NewGuid()
    }
    //==================

    Now the error is:
    The following error occurred:
    Reference to undeclared namespace prefix: 'd'.
    File:script.js
    Line:46
    Unspecified error

    Line 46 is the line with the location of the field on the form to enter the GUID. is the code wrong for that portion of the feild location?

    Thanks
    Paul
  • 07-31-2006 10:24 PM In reply to

    Re: Load Event - Generate GUID

    Hi,

    I think you have given incorrect prefix of field /d:tblCallAuditStorage,
    Give this /dfs:tblCallAuditStorage.

    I hope this will work for you.
    Thanks.
    K.Ramana Reddy / http://www.ggktech.com
    India.
  • 08-01-2006 10:33 AM In reply to

    • SPP_ACS
    • Not Ranked
    • Joined on 07-31-2006
    • USA
    • Posts 5

    Re: Load Event - Generate GUID

    K.Ramana:
    Thanks for takin a look at the code. If I change the "d" to "dfs", I come up with the error:
    'XDocument.DOM.selectSingleNode(...)' is null or not an object.
    File:script.js

    If I leave it as the "d", i get this error
    Reference to undeclared namespace prefix: 'd'.
    File:script.js

    So, any other ideas? Is it possible since the field is the GUID field that is submit to the database, I need a "dummy" field to gather the GUID string, then have the @CallAuditID equal that field by the click of a button?

    is there another way to call the field?
  • 08-01-2006 11:05 PM In reply to

    Re: Load Event - Generate GUID

    Hi,

    Check once your Xpath
    XDocument.DOM.selectSingleNode("/dfs:myFields/dfs:dataFields/dfs:tblCallAuditStorage/@CallAuditID") is correct?

    I hope this will help you.
    Thanks.
    K.Ramana Reddy / http://www.ggktech.com
    India.
  • 08-02-2006 12:10 PM In reply to

    Re: Load Event - Generate GUID

    Add this line to your namespaces:

    xmlns:d="http://schemas.microsoft.com/office/infopath/2003/dataFields"

    Also, see this HowTo for more info on namespaces:http://www.infopathdev.com/howto/tutorials/default.aspx?i=ed2cf0c5895f468995cdd081cf17fead
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
Page 1 of 1 (9 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.