Admin Services Apex Class Usage Guide
Overview
The AdminServices class provides administrative utility methods for configuring and maintaining QuickBooks Connector settings within Salesforce. These methods allow administrators and developers to manage QuickBooks credentials, initialize default endpoint configurations, and synchronize endpoint settings across multiple QuickBooks credential records.
Namespace: cm_finance
Class Name: AdminServices
Access Level: Global
Available Methods
1. updateQBCredentials
Description
Updates QuickBooks OAuth credentials and State URL for a specified QuickBooks Credential record.
This method supports both Sandbox and Production QuickBooks environments.
Method Signature
cm_finance.AdminServices.updateQBCredentials(
cm_finance.AdminServices.ServicesDataWrapper wrapper
);
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
stateURL |
String |
OAuth callback/state URL |
|
clientId |
String |
QuickBooks Client ID |
|
clientSecret |
String |
QuickBooks Client Secret |
|
apiInstance |
String |
Sandbox or Production |
|
credName |
String |
Name of the credential record |
Example – Sandbox Credentials
cm_finance.AdminServices.ServicesDataWrapper wrapper =
new cm_finance.AdminServices.ServicesDataWrapper();
wrapper.stateURL = 'https://example.com/oauth/callback';
wrapper.clientId = 'SANDBOX_CLIENT_ID';
wrapper.clientSecret = 'SANDBOX_CLIENT_SECRET';
wrapper.apiInstance = 'Sandbox';
wrapper.credName = 'Default';
cm_finance.AdminServices.updateQBCredentials(wrapper);
Example – Production Credentials
cm_finance.AdminServices.ServicesDataWrapper wrapper =
new cm_finance.AdminServices.ServicesDataWrapper();
wrapper.stateURL = 'https://example.com/oauth/callback';
wrapper.clientId = 'PRODUCTION_CLIENT_ID';
wrapper.clientSecret = 'PRODUCTION_CLIENT_SECRET';
wrapper.apiInstance = 'Production';
wrapper.credName = 'Default';
cm_finance.AdminServices.updateQBCredentials(wrapper);
Fields Updated
Sandbox Configuration:
cm_finance__State_URL__c
cm_finance__Sandbox_Client_ID__c
cm_finance__Sandbox_Client_Secret__c
Production Configuration:
cm_finance__State_URL__c
cm_finance__Client_ID__c
cm_finance__Client_Secret__c
2. updateEndpointsFromDefault
Description
Copies endpoint configurations from the Default QuickBooks Credential record to another credential record.
This method is useful when onboarding a new QuickBooks company and ensuring endpoint consistency.
Method Signature
cm_finance.AdminServices.updateEndpointsFromDefault(
cm_finance.AdminServices.ServicesDataWrapper wrapper
);
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
credName |
String |
Target credential record name |
Example
cm_finance.AdminServices.ServicesDataWrapper wrapper =
new cm_finance.AdminServices.ServicesDataWrapper();
wrapper.credName = 'Company A';
cm_finance.AdminServices.updateEndpointsFromDefault(wrapper);
Endpoints Copied
The following configurations are copied from the Default credential:
Create Account Endpoint
Create Customer Endpoint
Create Invoice Endpoint
Create Sales Receipt Endpoint
Create Product Endpoint
Update Product Endpoint
Create Vendor Endpoint
Create Payment Method Endpoint
Create Journal Ledger Endpoint
Company Info Endpoint
Invoice PDF Endpoint
Sales Receipt PDF Endpoint
Query Endpoint
Batch Endpoint
Preferences Endpoint
Access Token Endpoint
Base URL
Production Base URL
Minor Version
Typical Use Cases
-
New company onboarding
-
Package upgrades
-
Endpoint configuration resets
-
Synchronizing configuration across companies
3. updateDefaultCredentialsEndpoints
Description
Creates or updates the Default QuickBooks Credential record with the standard QuickBooks Online API endpoint configuration.
This method should typically be executed after installation or package upgrades.
Method Signature
cm_finance.AdminServices.updateDefaultCredentialsEndpoints();
Example
cm_finance.AdminServices.updateDefaultCredentialsEndpoints();
Endpoints Configured
OAuth Endpoint
https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer
Sandbox Base URL
https://sandbox-quickbooks.api.intuit.com
Production Base URL
https://quickbooks.api.intuit.com
Supported QuickBooks APIs
Account
Customer
Invoice
Sales Receipt
Item
Vendor
Journal Entry
Payment Method
Company Information
Query
Batch
Preferences
Invoice PDF
Sales Receipt PDF
Wrapper Classes
ServicesDataWrapper
Description
Wrapper class used to pass QuickBooks credential configuration details to Admin Services methods.
Definition
cm_finance.AdminServices.ServicesDataWrapper
Properties
|
Property |
Type |
Description |
|---|---|---|
|
stateURL |
String |
OAuth callback/state URL |
|
clientId |
String |
QuickBooks Client ID |
|
clientSecret |
String |
QuickBooks Client Secret |
|
apiInstance |
String |
Sandbox or Production |
|
credName |
String |
QuickBooks Credential record name |
Example
cm_finance.AdminServices.ServicesDataWrapper wrapper =
new cm_finance.AdminServices.ServicesDataWrapper();
wrapper.stateURL = 'https://example.com/oauth/callback';
wrapper.clientId = 'CLIENT_ID';
wrapper.clientSecret = 'CLIENT_SECRET';
wrapper.apiInstance = 'Sandbox';
wrapper.credName = 'Default';
Complete Setup Example
The following script demonstrates a typical setup process.
Step 1 – Initialize Default Endpoints
cm_finance.AdminServices.updateDefaultCredentialsEndpoints();
Step 2 – Configure QuickBooks Credentials
cm_finance.AdminServices.ServicesDataWrapper wrapper =
new cm_finance.AdminServices.ServicesDataWrapper();
wrapper.stateURL = 'https://example.com/oauth/callback';
wrapper.clientId = 'YOUR_CLIENT_ID';
wrapper.clientSecret = 'YOUR_CLIENT_SECRET';
wrapper.apiInstance = 'Sandbox';
wrapper.credName = 'Default';
cm_finance.AdminServices.updateQBCredentials(wrapper);
Step 3 – Copy Endpoints to Additional Company Configuration
cm_finance.AdminServices.ServicesDataWrapper companyWrapper =
new cm_finance.AdminServices.ServicesDataWrapper();
companyWrapper.credName = 'Company A';
cm_finance.AdminServices.updateEndpointsFromDefault(companyWrapper);