bhanushalimahesh3
bhanushalimahesh3

Reputation: 127

Quickbooks Desktop multiple entity custom fields

I am using web connector to communicate with QuickBooks desktop version and on web end I am using consolibyte https://github.com/consolibyte/quickbooks-php. Now I have a use case where I need to work with Customer and Employee custom fields. I am able to insert, update custom fields, all good till now. Here comes the problem, in a consolibyte library we define all actions

$map = array(QUICKBOOKS_MOD_DATAEXT  => array( 'employee_custom_field_request',
                                'employee_custom_field_response',
                                'customer_custom_field_request',
                                'customer_custom_field_response'
                                )

Now if I only need to update employee custom field I will enqueue request

$Queue = new QuickBooks_WebConnector_Queue('mysqli://username:password@localhost/quickbook'); $Queue->enqueue(QUICKBOOKS_MOD_DATAEXT, $id);

so whenever I will run web connector both customer and employee custom fields request & response function will get called, so how should I code to call only particular entity function (Either Customer or Employee) ?? Or is there any way in consolibyte library where we can differentiate between whose call is it ?

Upvotes: 4

Views: 124

Answers (1)

Keith Palmer Jr.
Keith Palmer Jr.

Reputation: 27952

There's a couple of options here --

These constants QUICKBOOKS_MOD_DATAEXT are totally arbitrary. e.g. you can do this instead:

$Queue->enqueue('CustomFieldForCustomer', $id);
$Queue->enqueue('CustomFieldForEmployee', $another_id);

You can use whatever you want there, as long as what you have in the call to ->enqueue(...) matches something in your $map. So just make up some new constants.

Another option, is to pass in extra additional data. e.g.:

$Queue->enqueue(QUICKBOOKS_MOD_DATAEXT, $your_id, null, array( 'this_is_for_a' => 'customer' );

Then when your function is called:

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 
    }
}

Upvotes: 1

Related Questions