Help with Conditional Code - InfoPath Dev
in

InfoPath Dev

Help with Conditional Code

Last post 07-03-2006 10:07 AM by Carolyn. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 07-03-2006 08:57 AM

    Help with Conditional Code

    I have worked this weekend to design code based on an old VBA code I had which worked very well for a Word Form which searched a Table for records to match based on Leave Request , Login and Start Date. If there was a match then the record updated a few fields, and that was all, If there was no Match (meaning that a record had not previously been added to the Table) a New Record with all the fields where added to the Table. So here is my attempt to write Jscript for InfoPath to do the same: Unfortunateky it errors

    function CTRL21_7::OnClick(eventObj)
    {
    //check the P3 field of Leave Records
    //created 6/30/06 by P. Trudell

    var Conn=Server.CreateObject("ADODB.Connection");
    Conn.Open("\\ourserver\op files\SAT2_be.mdb");

    var rst = Server.CreateObject("ADODB.Recordset");
    rst.Open"Select*from Leave";
    var LoginID = recordset.Fields.Item("StdLoginID").Value;
    var STDate = recordset.Fields.Item("STDate").Value;

    var Login = XDocument.DOM.SelectNodes("//dfs:myFields/dfs:dataFields/d:P-3 Request/@StdLoginID);
    var SDate = XDocument.DOM.SelectNodes("//dfs:myFields/dfs"dataFields/d:P-3 Request/@STDate);
    rst.MoveFirst;
    While(!rst.EOF){
    If Login == LoginID and SDate == STDate Then}
    rst.Fields('P3').Value="yes";
    rst.Fields('Auto_P3').Value="yes";
    rst.Update();
    rst.MoveNext;
    else
    rst.AddNew();
    rst.Fields('StdLoginID').Value =XDocument.DOM.SelectNodes("//dfs:myFields/dfs:dataFields/d:P-3 Request/@StdLoginID);
    rst.Fields('STdate').Value=XDocument.DOM.SelectNodes("//dfs:myFields/dfs:dataFields/d:P-3 Request/@STDate);
    rst.Fields('EndDate').Value=XDocument.DOM.SelectNodes("//dfs:myFields/dfs:dataFields/d:P-3 Request/@EndDate);
    rst.Fields('From').Value=XDocument.DOM.SelectNodes("//dfs:myFields/dfs:dataFields/d:P-3 Request/@From);
    rst.Fields('To').Value=XDocument.DOM.SelectNodes("//dfs:myFields/dfs:dataFields/d:P-3 Request/@To);
    rst.Fields('PerLv')Value=XDocument.DOM.SelectNodes("//dfs:myFields/dfs:dataFields/d:P-3 Request/@PerLv);
    rst.Fields('SickLv').Value=XDocument.DOM.SelectNodes("//dfs:myFields/dfs:dataFields/d:P-3 Request/@SickLv);
    rst.Fields('CompLv').Value=XDocument.DOM.SelectNodes("//dfs:myFields/dfs:dataFields/d:P-3 Request/@CompLv);
    rst.Fields('OthLv').Value=XDocument.DOM.SelectNodes("//dfs:myFields/dfs:dataFields/d:P-3 Request/@OthLv);
    rst.Fields('Remarks').Value=XDocument.DOM.SelectNodes("//dfs:myFields/dfs:dataFields/d:P-3 Request/@Remarks);
    rst.Fields('P3').Value= "yes";
    rst.Fields('Auto_P3').Value="yes";
    rst.Update();
    rst.Close()
    Conn.Close()

    }

    I am trying to learn this code, but can not find good references for what I want to do.

    Appreciate any assistance. Thanks
  • 07-03-2006 10:07 AM In reply to

    Re: Help with Conditional Code

    quote:
    Appreciate any assistance.

    "Any"?

    I'll tell you what I did when I was in the same situation. I am an experienced VBA script writer and struggled with jscript and vbscript when I first started with InfoPath.

    I gave up.

    I got Visual Studio and wrote script for InfoPath in VB.net. It's much easier and works like the VBA I'm used to.

    Just my 2 cents worth. Sorry, I can't even begin to debug your jscript.
Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.