Accessing Code for Submission - InfoPath Dev
in

InfoPath Dev

Accessing Code for Submission

Last post 06-09-2005 10:55 AM by jimmyfo. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 06-08-2005 09:27 AM

    Accessing Code for Submission

    Hi, I'm using rules for the submit to both drop the information to the database and publish to the SharePoint portal. I'm using a function to make the name of the file a concatanation of a static word and the primary key variable. My question is: if I am trying to submit the same value as one that already exists in the database as a primary key, I would like to append the next available number (starting at 1) to the end of the name. How would I do that, and if I were, where would I access and change the code that InfoPath is using to do the two submissions?

    Example:
    John Doe - existing primary key in database.
    ->trying to submit new John Doe (same name, different person)
    John Doe, John Doe1 - primary keys in database.

    Likewise, is it possible to delete simultaneously from the Portal and the Database?

    Thanks and regards,
    James

    EDIT: I am using custom code for the submit to the database and the portal - the problem now lies with checking if the name already exists in them (since they reflect each other exactly) and if they do, appending a number onto the end. How can I check the database and change the submission values instead of using XDocument.Submit()? The same with the portal drop. Thanks again - this would be a huge help.
  • 06-09-2005 10:55 AM In reply to

    Re: Accessing Code for Submission

    Hi, the code I'm testing the query with to see if the name exists is as follows:


    // Get the default SQL command for the form.
    var strOrigSQLCommand = XDocument.QueryAdapter.Command;

    // Get the query node that you want to check.
    //var queryName = XDocument.DOM.selectSingleNode("/dfs:myFields/dfs:dataFields/@name");

    //Set the value of the datafield.
    var queryName = XDocument.DOM.selectSingleNode("/dfs:myFields/dfs:dataFields/d:applicantTable/@name");

    // Construct the full query string.
    var strSQLQuery = strOrigSQLCommand;
    strSQLQuery = "select name '" + queryName.text + "' from applicantTable";

    // This is the query.
    XDocument.UI.Alert(strSQLQuery);

    // Run the query.
    XDocument.QueryAdapter.Command = strSQLQuery;
    try
    {
    XDocument.Query();
    XDocument.UI.Alert("No Value for name in database.");
    }
    catch(ex)
    {
    XDocument.UI.Alert("Name in database or invalid return." + ex.number + " " + ex.description);
    }

    // Restore the default table command (for the next time).
    XDocument.QueryAdapter.Command = strOrigSQLCommand;
    }


    The error message I get on runtime is:


    The following error occurred:

    The query method on the Document object failed.
    InfoPath cannot run the specified query.
    The XML data returned from the data source does not match the XML Schema for this form. This discrepancy might be caused by the data source returning multiple rows when InfoPath expects only one.
    Attribute 'James_Fogarty' is not allowed on element 'http://schemas.microsoft.com/office/infopath/2003/ado/dataFields}applicantTable', according to Schema.


    File:script.js
    Line:150



    Any ideas?

    Thanks.

    James
Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.