Jscript error - InfoPath Dev
in

InfoPath Dev

Jscript error

Last post 03-14-2007 01:54 PM by Greg Collins. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 03-13-2007 10:50 AM

    Jscript error

    I am trying to use an Active X object to send certain fields for my form to a particular email group and I can get the email to go, but am having trouble getting the info from the fields into the message body.

    Here is the code for the email.
    //=======
    // The following function handler is created by Microsoft Office InfoPath.
    // Do not modify the name of the function, or the name and number of arguments.
    //=======
    function CTRL11_9::OnClick(eventObj)
    {
    // Create a new message and fill all its fields
    var iMsg = new ActiveXObject("CDO.Message");
    iMsg.To = "[email protected]";
    iMsg.From = "[email protected]";
    iMsg.Subject = "Termination Form";
    iMsg.TextBody = "Department : \'" + XDocument.DOM.selectSingleNode("/dfs:datafields/dfs:Termination/@Department").text;

    // Set SMTP server

    iMsg.Configuration.Fields
    ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "crmcexchm1.crmc.com"
    // Use the SMTP over the netowrk for sending method

    iMsg.Configuration.Fields
    ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2;
    // Make persistent
    iMsg.Configuration.Fields.Update();

    // Send the message
    iMsg.Send();


    }

    I have secondary namespaces in the form and verfied the xpath using expression boxes. The object required error keeps showing up.
    All of the fields I am trying to send are in the main dom.

    Here is the code for the namespaces.
    // The following line is created by Microsoft Office InfoPath to define the prefixes
    // for all the known namespaces in the main XML data file.
    // Any modification to the form files made outside of InfoPath
    // will not be automatically updated.
    //<namespacesDefinition>
    XDocument.GetDOM("Employee Info").setProperty("SelectionNamespaces" , 'xmlns:d="http://schemas.microsoft.com/office/infopath/2003/ado/dataFields" xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"')
    XDocument.GetDOM("Department List").setProperty("SelectionNamespaces" , 'xmlns:d="http://schemas.microsoft.com/office/infopath/2003/ado/dataFields" xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"')
    XDocument.DOM.setProperty("SelectionNamespaces", 'xmlns:q="http://schemas.microsoft.com/office/infopath/2003/ado/queryFields" xmlns:d="http://schemas.microsoft.com/office/infopath/2003/ado/dataFields" xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-02-20T16:59:23" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"');
    //</namespacesDefinition>

    I have researched this over and over have tried several ideas off of this forum and others as well. Any help woul be greatly appreciated.

    Thanks
  • 03-13-2007 11:19 AM In reply to

    Where exactly is the object required error coming from? If your form is not set to full-trust, then it might be coming from the creation of the ActiveX control.
  • 03-13-2007 12:16 PM In reply to

    After I hit the send button for the Activex Object it gives me the message for the Activex object might be unsafe and so on. I click ok on that and the error references Line 142 in my code and that is the
    iMsg.TextBody line of my code. If I put just plain text in that line it works just fine, not sure what the problem is when I try to access my fields.

    Thanks
  • 03-13-2007 12:23 PM In reply to

    My guess is a security issue. Try going to full trust and either signing or registering your form to see if the problem goes away.
  • 03-13-2007 12:49 PM In reply to

    My form is fully trusted via a certificate. Has been since I created it.

    Thanks
  • 03-13-2007 02:45 PM In reply to

    Not that it should matter, but you statement doesn't place a closing single quote on the body text.

    Anyhow -- I know you said that you verified the XPath via an expression box, but try getting the field value first into a variable and then use the variable to build the TextBody property value:

    var dept = XDocument.DOM.selectSingleNode("/dfs:datafields/dfs:Termination/@Department").text;
    iMsg.TextBody = "Department : '" + dept + "'";

    Then see where the error comes in -- from getting the node value or setting the TextBody property still.
  • 03-14-2007 10:03 AM In reply to

    It was coming in at the variable. But I figured it out. I had some typos in my XDocument line.

    Thanks for the help.
  • 03-14-2007 01:54 PM In reply to

    Great! Glad you were able to get it going. I'm glad to have been of help.
Page 1 of 1 (8 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.