【问题标题】:quickbooks desktop web connector qbxml add job continueOnError not workingquickbooks 桌面 Web 连接器 qbxml 添加作业 continueOnError 不起作用
【发布时间】:2015-04-08 04:36:35
【问题描述】:

我正在使用 QuickBooks Enterprise,Web 连接器版本:2.1.0.30 和在此处找到的框架:https://github.com/consolibyte/quickbooks-php
添加作业时,某些情况下存在相同的作业名称,因此 quickbooks 会出错。我希望进程在错误发生后继续,因此我将 onError 属性设置为“continueOnError”,如下所述:https://developer-static.intuit.com/qbSDK-current/Common/newOSR/qbsdk/staticHtml/QBD-Attributes.html,但进程停止并且下一个请求(添加发票)不执行。我必须重新运行才能处理下一个请求。 这是我的 xml 的一部分:

<?xml version="1.0" encoding="utf-8"?>
    <?qbxml version="2.0"?>
    <QBXML>
          <QBXMLMsgsRq onError="continueOnError">
               <CustomerAddRq requestID="...">
                   <CustomerAdd> ...

我在这里做错了什么?这是要走的路还是我需要做其他事情?
提前致谢。

【问题讨论】:

    标签: quickbooks qbxml


    【解决方案1】:

    stopOnErrorcontinueOnError 标志指示如果当前请求中发生错误,当前请求的剩余部分要做什么(停止或继续)。

    例如,如果您这样做:

    <?xml version="1.0" encoding="utf-8"?>
    <?qbxml version="2.0"?>
    <QBXML>
          <QBXMLMsgsRq onError="continueOnError">
               <CustomerAddRq requestID="1">
               ...
               </CustomerAddRq>
               <InvoiceAddRq requestID="2">
               ...
               </InvoiceAddRq>
           ....
    

    您告诉 QuickBooks,如果在 CustomerAddRq 部分发生错误,请忽略它并继续处理 InvoiceAddRq 部分(与如果您使用 stopOnError 相比,它甚至不会在遇到 InvoiceAddRq 后尝试CustomerAddRq 部分出错。

    但是,如果您正确使用了 Web 连接器(您是正确的),那么您将发送多个单独的请求,而不是像上面示例中那样发送一个批处理请求。这意味着 stopOnErrorcontinueOnError 不是您需要的。

    相反,您需要使用错误处理程序来处理 PHP 代码中的错误。

    添加功能:

    /** 
     * Try to handle an error 
     * 
     * @param string $requestID
     * @param string $user         This is the username of the connected Web Connector user
     * @param string $action       The action type that experienced an error (i.e. QUICKBOOKS_ADD_CUSTOMER, or QUICKBOOKS_QUERY_CUSTOMER, or etc.)
     * @param string $ID           The $ID value of the record that experienced an error (usually your primary key for this record)
     * @param array $extra 
     * @param string $err          If an error occurs **within the error handler**, put an error message here (i.e. if your error handler experienced an internal error), otherwise, leave this NULL
     * @param string $xml
     * @param string $errnum       The error number or error code which occurred
     * @param string $errmsg       The error message received from QuickBooks 
     * @return boolean             Return TRUE if the error was handled and you want to continue processing records, or FALSE otherwise
     */
    function my_error_handler($requestID, $user, $action, $ID, $extra, &$err, $xml, $errnum, $errmsg)
    {
        // ...
        // return true;     // return TRUE if you want the Web Connector to continue to process requests
        // return false;    // return FALSE if you want the Web Connector to stop processing requests and report the error
    }
    

    并确保将新的错误处理函数告诉 QuickBooks PHP 库:

    $errmap = array(
        // This is an array mapping the error number/code to the error handler function
        3070 => 'my_error_handler', 
    
        // You can also use static method error handlers if you don't like functions...
        // 3070 => 'MyStaticClass::myStaticMethod', 
    
        // ... or object instant error handlers.
        // 3070 => array( $MyObjectInstance, 'myMethod' ), 
    
        // You can also register a "catch-all" error handler to catch all errors:
        // '*' => 'my_catchall_error_handler', 
        );
    

    更多信息:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-04
      • 1970-01-01
      相关资源
      最近更新 更多