我正在使用网络连接器与 QuickBooks 桌面版进行通信,在网络端我正在使用 consolibyte https://github.com/consolibyte/quickbooks-php .现在我有一个用例,我需要使用客户和员工自定义字段。我能够插入、更新自定义字段,到目前为止一切正常。问题来了,在一个consolibyte库中我们定义了所有的 Action
$map = array(QUICKBOOKS_MOD_DATAEXT => array( 'employee_custom_field_request',
'employee_custom_field_response',
'customer_custom_field_request',
'customer_custom_field_response'
)
现在,如果我只需要更新员工自定义字段,我将排队请求
$Queue = new QuickBooks_WebConnector_Queue('mysqli://username:password@localhost/quickbook'); $Queue->enqueue(QUICKBOOKS_MOD_DATAEXT, $id);
所以每当我运行 Web 连接器时,客户和员工自定义字段请求和响应函数都会被调用,那么我应该如何编码以仅调用特定实体函数(客户或员工)?或者在 consolibyte 库中有什么方法可以区分是谁的调用?
最佳答案
这里有几个选项 --
这些常量 QUICKBOOKS_MOD_DATAEXT
是完全任意的。 例如你可以这样做:
$Queue->enqueue('CustomFieldForCustomer', $id);
$Queue->enqueue('CustomFieldForEmployee', $another_id);
只要调用 ->enqueue(...)
的内容与 $map
中的内容匹配,您就可以在那里使用任何内容。所以只要补一些新的常量。
另一种选择是传入额外的附加数据。例如:
$Queue->enqueue(QUICKBOOKS_MOD_DATAEXT, $your_id, null, array( 'this_is_for_a' => 'customer' );
然后当你的函数被调用时:
function CUSTOMER_OR_EMPLOYEE_custom_field_request($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $xml, $idents)
{
if ($extra['this_is_for_a'] == 'customer')
{
// ... do something for customers
}
else
{
// ... do something for employees
}
}
关于php - Quickbooks Desktop 多实体自定义字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51442146/