We all know that moment when you are running a Salesforce project for a couple of months (or even years), and we need to do a configuration review.
Which field is not used anywhere, which permission set is assigned to which user, do we have duplicates in our custom labels…
Tricky right?
What if you had the opportunity to retrieve all this info with just a query.
And be sure, Admins will use it even more than developers
How to Track Employee Performance A Comprehensive Guide.pdf
The tooling Api demystified, It is not only for developers, Doria Hamelryk & Fabrice Challier
1. The tooling Api demystified,
it is not only for developers!
by Doria Hamelryk & Fabrice Challier
2. #CD22
Who are we?
Fabrice CHALLIER Doria HAMELRYK
Managing Director @Little Chaman
Salesforce Technical Lead
Salesforce Trainer @ISDI (dex450,dex602)
Toulouse, France User Group Community Group Leader
Managing Director @GetMarcel
Salesforce Architect - 15x certified - MVP
Paris, France Women in Tech Community Group Leader
Organisation Team member of :
🇲🇦 North Africa Dreamin’ (Casablanca)
🇫🇷 French Touch Dreamin’ (Paris)
3. #CD22
● Present the Tooling Api
● Explain how it can be used by Admins
● Show Use Cases and Ready-to-use scripts
Objectives of this session
4. #CD22
Definition
APIs are a set of functions and procedures that allow an application to query or modify
data from another application without accessing it directly.
Request
Response
What is an API? (Application Programming Interface)
5. #CD22
Different API for different usage
● Depending on which element you want to work on :
● Many API’s are available for each type of element
Tooling API
Metadata API
Rest API
Soap API
Bulk API
Streaming API
Metadata
Data Event
API’s in the Salesforce World
6. #CD22
If it’s config or dev,
then it’s Metadata!
(and if it’s related to
records, then it’s not…)
What are Metadata?
7. #CD22
Metadata API Tooling API (since Spring ‘2013)
available in SOAP only available in REST, SOAP and SOQL
Retrieve results in nodes Retrieve results in list
Used for configuration migration Used for platform for debugging, code coverage,…
Results - Shared info (with Metadata API):
Results - Additional info:
Select
CreatedById, CreatedBy.Name, CreatedDate, fullname, Id, LastModifiedById,
LastModifiedBy.Name, LastModifiedDate, ManageableState, Description,
ErrorDisplayField, ErrorMessage, ValidationName, Active
from ValidationRule
where EntityDefinition.DeveloperName ='Case' and Id='03d3z000000QlbjAAC'
Tooling API Query :
Difference between Metadata API & Tooling API
13. #CD22
select
Id,CreatedBy.Name, CreatedDate, LastModifiedBy.Name, LastModifiedDate,
DeveloperName, EntityDefinition.DeveloperName, Description
from CustomField
“I want to see ALL custom fields created and check if they all have a description.”
Use Case : Custom Fields
14. #CD22
The EntityDefinition : key for everything
select DeveloperName from CustomField where…
Standard Field?
Then use the ID directly with the Object API
…EntityDefinitionId ='Case’
Custom Field?
Then use the QualifiedApiName with the Object API
…EntityDefinition.QualifiedApiName = ‘MyObject__c’
OR
DeveloperName without ‘__c’
…EntityDefinition.DeveloperName = ‘MyObject’
16. #CD22
select
DurableId,DeveloperName, issearchable, IsReportingEnabled, IsFieldHistoryTracked
from EntityDefinition
where PublisherId ='<local>' and qualifiedapiname like '%__c'
“I want to see on which custom object I can perform searches, reporting and history
tracking”
Use Case : Custom objects search & reporting
17. #CD22
Select
Id, EntityDefinition.DeveloperName, Active, ValidationName, ErrorDisplayField,
ErrorMessage, Description
from ValidationRule
“I want to see all validation rules, check if they are active or not and if error messages
are homogeneous (wording)”
Use Case : Validation rules definition
19. #CD22
select
Id, Name, TableEnumOrId
from Layout
where Id not in (select LayoutId from ProfileLayout) and layoutType ='Standard'
“I want to list all layout that are not assigned to any profile”
Use Case : Layout assignment
20. #CD22
select
MasterLabel, ProcessType, RunInMode, Status, Description
from Flow
where Status != 'Obsolete'
“I want to clean up my Automation (and kill Process Builders!)”
Use Case : Automation analysis
21. #CD22
select
Type, Label, Remaining, Max, EntityDefinitionid
from EntityLimit
where EntityDefinitionid='Account'
“I want to monitor my object limit”
Use Case : Limits monitoring
⚠️ Requires EntityDefinitionId or DurableId filter
22. #CD22
select
MetadataComponentId, MetadataComponentName, MetadataComponentType,
RefMetadataComponentId, RefMetadataComponentName,RefMetadataComponentType
from MetadataComponentDependency
where MetadataComponentType = 'Layout' and RefMetadataComponentType='CustomField'
“I want to know which custom field is never displayed on layouts”
Use Case : Unused Fields (Step 1 on 3)
Layout ID Field ID
Layout Name Field API
25. #CD22
Be careful with
MetadataComponentDependency
Never forget Salesforce limits :)
● You can only retrieve 2k records with
your query
● If you have > 2k records,
results will be truncated,
and not necessary to 2k records :)
● You don’t have any warning !
26. #CD22
select
ApiVersion, Category, DeveloperName, IsReleased, ReleaseLabel,
SupportsRevoke, StepStage, Title, Description
from ReleaseUpdate where IsReleased=false
“I want to monitor all release updates and
check actions that need to be performed”
Use Case : Release updates
27. #CD22
select
CreatedBy.Name, CreatedDate, Description, EndDate, LicenseType, SandboxInfoId,
SandboxName, source.SandboxName, Status, SystemModstamp from SandboxProcess
“I want to list all my sandboxes and their history (creation, refresh, delete)”
Use Case : Sandbox monitoring
29. #CD22 29
● Tooling API is a powerful tool to retrieve Config and Dev information
● It can be used by anyone having basic knowledge of SOQL
● It’s possible to automate Health Check with the Tooling API
● All capabilities are documented on
https://developer.salesforce.com/docs/atlas.en-
us.234.0.api_tooling.meta/api_tooling/reference_objects_list.htm
Tooling API: Summary
30. #CD22 30
To go further
Ask help to your developer buddies if you don’t know how to
build your query.
Who knows, he/she could also learn something new :)
Do not hesitate to contact us if you have any question :
Doria Hamelryk : doria.hamelryk@gmail.com
Fabrice Challier : fabricechallier@gmail.com
This presentation and all the queries are available here :
bit.ly/cztooling