eMail submission code breakdown - InfoPath Dev
in

InfoPath Dev

eMail submission code breakdown

Last post 03-14-2006 03:16 PM by StuartMiller. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 03-14-2006 07:42 AM

    eMail submission code breakdown

    I have a block of code for InfoPath, trying to submit a form through email and read the control text fields to concatenate them in plain text form in the Intro segment of the email so that Blackberry users will be able to read the data. My code worked on an old form, before I rebuilt the form to be based on a database. Now it won't seem to read the control values at all. It's a long block of code:

    XDocument.DOM.setProperty("SelectionNamespaces", 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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/2006-03-08T23:17:48" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003"');
    //</namespacesDefinition>
    //=======
    // 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 cmdSubmit::OnClick(eventObj)
    {
    var strSubject = "EPOReq:";
    var strAttachment = "EPOReq:";
    var strIntro;

    var JobNumber;
    var Priority;
    var Address;
    var Vendor;
    var EPOType;
    var VarCode;
    var CostType;
    var CostCode;
    var Invoice;
    var Amount;
    var Desc;

    var BACvendor = "Backcharged Vendor: \t";
    var BACform = "Backcharge Form: \t";
    var BACinvoice = "Backcharge Invoice: \t";
    var BACamount = "Backcharge Amount: \t";

    var objRepeatingNodes = XDocument.DOM.selectNodes("//dfs:myFields/dfs:dataFields/@EPORequestLog");
    var objJobNumber = XDocument.DOM.selectNodes("//dfs:myFields/dfs:dataFields/d:EPORequestLog/@Job_Number");
    var objPriority = XDocument.DOM.selectNodes("//dfs:myFields/dfs:dataFields/d:EPORequestLog/@Priority");
    var objAddress = XDocument.DOM.selectNodes("//dfs:myFields/dfs:dataFields/d:EPORequestLog/@Address");
    var objVendor = XDocument.DOM.selectNodes("//dfs:myFields/dfs:dataFields/d:EPORequestLog/@Vendor");
    var objEPOType = XDocument.DOM.selectNodes("//dfs:myFields/dfs:dataFields/d:EPORequestLog/@EPO_type");
    var objVarCode = XDocument.DOM.selectNodes("//dfs:myFields/dfs:dataFields/d:EPORequestLog/@Variance_Code");
    var objCostType = XDocument.DOM.selectNodes("//dfs:myFields/dfs:dataFields/d:EPORequestLog/@Cost_Type");
    var objCostCode = XDocument.DOM.selectNodes("//dfs:myFields/dfs:dataFields/d:EPORequestLog/@Cost_Code");
    var objInvoice = XDocument.DOM.selectNodes("//dfs:myFields/dfs:dataFields/d:EPORequestLog/@Invoice_Number");
    var objAmount = XDocument.DOM.selectNodes("//dfs:myFields/dfs:dataFields/d:EPORequestLog/@EPO_Amount");
    var objDesc = XDocument.DOM.selectNodes("//dfs:myFields/dfs:dataFields/d:EPORequestLog/@Description");

    var objBACvendor = XDocument.DOM.selectNodes("//dfs:myFields/dfs:dataFields/d:EPORequestLog/d:BackchargeInfo/@BackchargedVendor");
    var objBACform = XDocument.DOM.selectNodes("//dfs:myFields/dfs:dataFields/d:EPORequestLog/d:BackchargeInfo/@BACFormNumber");
    var objBACinvoice = XDocument.DOM.selectNodes("//dfs:myFields/dfs:dataFields/d:EPORequestLog/d:BackchargeInfo/@BACInvoiceNumber");
    var objBACamount = XDocument.DOM.selectNodes("//dfs:myFields/dfs:dataFields/d:EPORequestLog/d:BackchargeInfo/@BackchargedAmount");

    var Intro = "Job Number:\t\t";

    for (var i=0; i < objRepeatingNodes.length; i++)
    {
    JobNumber = objJobNumber.item(i).text.concat("\r\n Address:\t\t");
    if (objPriority.item(i).text = "Normal")
    {
    }
    else
    {
    Priority = objPriority.item(i).text.concat("\r\n Priority:\t\t");
    }
    Address = objAddress.item(i).text.concat("\r\n Vendor:\t\t");
    Vendor = objVendor.item(i).text.concat("\r\n EPO Type:\t\t");
    EPOType = objEPOType.item(i).text.concat("\r\n Variance Code:\t");
    VarCode = objVarCode.item(i).text.concat("\r\n Cost Type:\t\t");
    CostType = objCostType.item(i).text.concat("\r\n Cost Code:\t\t");
    CostCode = objCostCode.item(i).text.concat("\r\n Invoice #:\t\t");
    Invoice = objInvoice.item(i).text.concat("\r\n EPO Amount:\t");
    Amount = objAmount.item(i).text.concat("\r\n Description:\t");
    Desc = objDesc.item(i).text.concat("\r\n");

    Intro = Intro.concat(JobNumber);
    Intro = Intro.concat(Address);
    Intro = Intro.concat(Vendor);
    Intro = Intro.concat(EPOType);
    Intro = Intro.concat(VarCode);
    Intro = Intro.concat(CostType);
    Intro = Intro.concat(CostCode);
    Intro = Intro.concat(Invoice);
    Intro = Intro.concat(Amount);
    Intro = Intro.concat(Desc);

    if (objVarCode.item(i).text = "BAC")
    {
    BACvendor = "\r\nBackcharged Vendor: \t";
    BACvendor = BACvendor.concat(objBACvendor.item(i).text);
    BACform = "\r\nBackcharge Form: \t\t";
    BACform = BACform.concat(objBACform.item(i).text);
    Intro = Intro.concat(BACvendor);
    Intro = Intro.concat(BACform);
    //if (objBACinvoice.item(i).text = "0")
    // {
    // }
    // else
    // {
    BACinvoice = "\r\nBackcharge Invoice: \t";
    BACinvoice = BACinvoice.concat(objBACinvoice.item(i).text);
    Intro = Intro.concat(BACinvoice);
    // }
    BACamount = "\r\nBackcharge Amount: \t";
    BACamount = BACamount.concat(objBACamount.item(i).text);
    BACamount = BACamount.concat("\r\n\r\n");
    Intro = Intro.concat(BACamount);
    }

    if (i+1 < objRepeatingNodes.length)
    {
    Intro = Intro.concat("\r\nJob Number:\t\t");
    }

    strSubject = strSubject.concat("_");
    strSubject = strSubject.concat(objJobNumber.item(i).text);
    strAttachment = strAttachment.concat("_");
    strAttachment = strAttachment.concat(objJobNumber.item(i).text);

    }

    var strProcessor;
    strProcessor = XDocument.DOM.selectNodes("//my:myFields/my:Submission/my:Processor");
    Intro = Intro.concat("\r\n EPO Processor: ");
    Intro = Intro.concat(strProcessor.text);

    strAttachment = strAttachment.concat(".xml");

    var strTo = XDocument.DOM.selectNodes("//my:myFields/my:Submission/my:SubmitForApproval");

    var oEmail;
    oEmail = XDocument.DataAdapters("eMail");
    oEmail.Subject = strSubject;
    oEmail.AttachmentFileName = strAttachment;
    //email's body
    oEmail.Intro = Intro;
    //Set the To: Address
    oEmail.To = strTo.text
    //Submit the email
    oEmail.Submit();
    }

    Any ideas, JScript code gurus?

    Thanks!
  • 03-14-2006 11:52 AM In reply to

    Re: eMail submission code breakdown

    Hi Stuart,
    Welcome to the Forum!
    Please point us where your code is failing, if you give so much code we don't get that much time to parse through all of the code.
  • 03-14-2006 03:16 PM In reply to

    Re: eMail submission code breakdown

    Sorry.

    The problem seems to be that, even though I don't get an error message, the program is not pulling the value of the controls I reference. Any of them, really. I have checked the XPath of my controls many times, and they seem valid.

    I have made several observations that I can't explain. The same code works in a form that is not based on a database (the only difference in code between the two forms is the appropriate XPaths to the controls).

    However, the form that is based on an Access Database won't seem to access the controls. I have a few controls (those stored in variables not used in the For loop) that are not in a repeating table, and I should be able to use the selectSingleNode method. However, that method errors out with "Object Required" (line 158, for example, if I change it to selectSingleNode).

    This makes no sense to me, since selectSingleNode, as I understood it, actually internally utilizes selectNodes. However, I get no error message using selectNodes, even though the program doesn't seem to pull any information (.text) from those nodes/controls.

    So the basic problem is that I can't seem to programmatically access the information stored in the various text fields and listboxes that I'm referencing in order to concatenate a string in the Intro body of my email submission.

    Is there any difference between how selectNodes is used in a form built on a database and a form not based on a database?

    Any idea what I'm missing?
Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.