Workbench is a powerful, web-based suite of tools designed to interact with Salesforce.com organizations via the Force.com APIs.
This article describes various important topics of Salesforce Workbench:
- Data Manipulation using workbench.
- Usage of REST API and Asynchronous methods in workbench.
- Migration via workbench.
- Difference between developer console and workbench.
- Scenarios describing workbench’s functionalities.
Salesforce Workbench Login
- Login into Workbench using the following URL.
- Select the Environment, API Version and enter the Salesforce Credentials.
- Salesforce Workbench gets displayed after successful login.
- Data Manipulation using workbench
Navigate to ‘Data’ tab to perform various data manipulation operations.
1.1 To perform Insert, Update and Upsert operations,
- Select an object from the ‘Object Type’ drop-down.
- Select either ‘Single record’ or ‘From file’ option and click Next.
- Upload any valid CSV or ZIP file in the ‘From File’ option.
- Click ‘Confirm’ button to confirm the number of Insert / Update / Upsert records.
- Upon successful data manipulation operation, the screen displays,
- Salesforce ID of the records
1.2 To perform Delete, Undelete and Purge operations,
- Select either ‘Single record’ or ‘From File’ option and click Next.
- Enter the record ID (Salesforce ID) to Delete, Undelete or Purge.
- Click the ‘Confirm’ button to confirm the number of Delete / Undelete / Purge records.
- Workbench displays the ‘Salesforce ID’ and the status of the result after successful data manipulation.
- Usage of REST API and Asynchronous methods in workbench
2.1 REST Explorer
REST Explorer in workbench helps the user to explore and discover the REST API, thus enabling the user to retrieve, create, update or delete the data in the Salesforce org.
- Navigate to the ‘Utilities’ tab and select ‘REST Explorer’
- By default, the HTTP method is set to ‘GET’.
- Clicking the ‘Headers’ button displays the ‘Request Headers’
- The response is set to ‘JSON’ format by default. It can also be changed to ‘XML’
2.1.1 HTTP Methods in REST API
Method 1: POST
- For creating records using REST API, ‘POST’ method is used.
- Make sure to set the connection is set as ‘/sobjects/URI’.
- Set the ‘Request Body’ with fields and its values.
- Click ‘Execute’ button to receive the response message confirming successful insertion.
Method 2: GET
- To read a record from Salesforce org, ‘GET’ method is used.
- Set the SOQL query that returns all the records present in the Salesforce org.
- Click ‘Execute’ button to receive the success message as well as the ‘Raw Response’.
Method 3: PATCH
- For editing / updating records through REST API, ‘PATCH’ method is used.
- Set the ‘Request Body’ with fields and values for updating the records.
- Click ‘Execute’ button to receive the response [‘Raw Response’] message.
Method 4: DELETE
- To delete records through REST API, ‘DELETE’ method is used.
- Set the URI according to the object to be deleted and enter its related ID.
- Click the ‘Execute’ button to receive the response message confirming successful deletion.
2.2 Asynchronous methods in workbench
Apex code and the Status of the API jobs can be executed in workbench through Asynchronous methods.
2.2.1 Apex Execute
- Using Apex Execute the user can create, update and delete the records.
- Navigate to Utilities à Apex Execute.
- Enter the Apex Code in the provided space, that work as an Anonymous window.
- Select the ‘Log category’ as ‘Apex Code’ and ‘Log Level’ as ‘Debug’.
- Click the ‘Execute’ button to see the results of the Apex Execution in the same window.
2.2.2 Bulk API Job Status
- Bulk API Job Status is used to display the ‘Asynchronous data load status and results’
- Navigate to Utilities à Bulk API Job Status.
- Enter the ‘Job ID’ in the provided text box.
- Click ‘Get Status’ button to fetch the status of the Bulk data jobs and display in the same window.
- Migration via Workbench
Migration in workbench helps the user to ‘Retrieve’ and ‘Deploy’ the Metadata components that help structure the organization like custom applications, objects and other components.
To retrieve Metadata components from the organization,
- Prepare an XML file with standards and types defined with the version of API for the request.
- Navigate to Migration à Retrieve
- In the Unpackaged Manifest section, select the created package XML file to obtain the component attributes.
- Optionally, enter the ‘Package Names’ and select the ‘Single Package’ check box and click Next.
- Upon successful upload of the XML file, Click the ‘Retrieve’
- Click on ‘Download ZIP File’ to view the deployed Metadata components from the organization.
To deploy the Metadata components to the organization,
- Create a folder with ‘Package XML’ in the root and a sub level folder with the component name. ZIP the folder.
- Navigate to Migration à Deploy
- In Choose section, select the folder with the Package XML to deploy the Metadata components.
- Optionally, select the below check boxes and click Next.
- Upon successful upload, click the ‘Deploy’
- Confirm the results deploy successfully, if not check the files for any errors.
4.Difference between Developer Console and Workbench
Salesforce Object Query Language (SOQL) and Salesforce Object Search Language (SOSL) Queries can be executed both in developer console as well as in workbench.
The major difference between using developer console and workbench is the User Interface. Workbench provides users an enhanced UI to query the records.
- The SOQL queries can be built just by selecting the ‘Object’ and ‘fields’ drop-down.
- Queries can be filtered by using ‘Sort results by’ and ‘Filter results by’ drop-down.
- In workbench, the query results can be viewed as,
- Bulk CSV
- Bulk XML
- The records that are deleted and archived can be either excluded or included.
- The results of SOQL query can be exported through ‘Bulk CSV’ option to analyze the data for future use.
- The SOSL queries can be built by specifying the ‘Search for’ and ‘Returning object’ options.
- The results of the SOSL queries are displayed in the List format specifying the ID’s. Hover over the ID’s to perform actions such as,
- View in Salesforce
5.Scenarios describing Workbench’s functionalities
A user is asked to find out the count of Metadata components in a Salesforce organization.
To achieve this using workbench,
- Navigate to Info Tab à Metadata Types & Components.
- Select any Metadata from the list of drop-down.
- Upon selection, workbench describes and displays the ‘Total Number of Components’ present in the particular Metadata.
Export data for the Users who are assigned to Permission sets.
To achieve this scenario using Workbench,
- Navigate to Queries à SOQL Query
- Select ‘PermissionSetAssignment’ in the object drop-down and the necessary fields.
- Select ‘Bulk CSV’ in View as option and Click Query.
- This will take the user to a next screen displaying the Job ID and status of the Job.
- Click the download [ ] button to export the SOQL query into a CSV file.
A user could not log in and was not getting the password reset email when tried to reset the password.
To achieve this using workbench,
- Navigate to Utilities à Password Management
- Click the ’Reset’ option and enter the User ID.
- Click ‘Change Password’ button to reset the password.
- Click on the ‘Set’ option and enter the User ID.
- Enter the values for the fields ‘Password’ and ‘Confirm password’.
- Click ‘Change Password’ to change the password for the user.
Advantages of workbench
- It gives us access to data and structural info from all objects in the system.
- For Frozen or Locked users, SOQL queries in Workbench helps to view the data.
- Those on Mac can use it without additional software.
Disadvantages of workbench
- Workbench has an inability to save and reuse data load mappings, as we can do with the data loader.
- Workbench does not have an ability to do command line or scheduled actions, as with data loader.