I can submit an ApexExecutionOverlayAction GET request using REST API and I get an ID in response. But how do I use the ID? How can I see the ApexExecutionOverlayResult for my ApexExecutionOverlayAction request?
I wish SFDC had better documentation for the Tooling API.
Attribution to: prashanthkr
Possible Suggestion/Solution #1
The below is working for me using the workbench.
POST /services/data/v38.0/tooling/sobjects/ApexExecutionOverlayAction
{
"ActionScript" : "SELECT Id FROM Account WHERE Id = '001[ACCOUNT-ID]'",
"ActionScriptType" : "SOQL",
"ExecutableEntityId" : "01p[CLASS_ID]",
"IsDumpingHeap" : "true",
"Iteration" : "1",
"Line" : "29",
"ScopeId" : "005[USER-ID]"
}
Or if you want to run Apex, it looks like this
{
"ActionScript" : "System.debug('Todd overlays'); System.debug([SELECT Id FROM Account WHERE Id = '001[ACCOUNT-ID]']);",
"ActionScriptType" : "Apex",
"ExecutableEntityId" : "01p[CLASS_ID]",
"IsDumpingHeap" : "true",
"Iteration" : "1",
"Line" : "29",
"ScopeId" : "005[USER-ID]"
}
That returns me an ID like 1doe00000000123 (not a real ID) I will probably need that later.
But for now, I need the result ID. Here's a basic query you can use:
GET /services/data/v38.0/tooling/query/?q=SELECT+Id+FROM+ApexExecutionOverlayResult+ORDER+BY+CreatedDate+DESC+LIMIT+1
That gets me an ID such as 07ne00000001234 (not a real ID). Then the details are available at
GET /services/data/v38.0/tooling/sobjects/ApexExecutionOverlayResult/07ne00000001234
When I do Apex rather than SOQL I wish I could get at instance variable values but it's not impossible to recreate them.
Two other notes.
- If I don't specify an expiration date I get a default of 30 mins in the future
- You can only have one Action for a give class and line. So if you need to alter it, delete your old one with:
DELETE /services/data/v38.0/tooling/sobjects/ApexExecutionOverlayAction/1doe00000000123
Attribution to: Todd
Possible Suggestion/Solution #2
You will need to execute the Apex Class/Trigger in question to hit the checkpoint. You must have the Apex Code log level set to Finer or Finest.
From Setting Checkpoints in Apex Code:
Important
To use checkpoints, the Apex Log Level must be set to Finer or Finest. See Setting Logging Levels.
Retrieving the results:
There doesn't currently appear to be any direct queryable relationship between a ApexExecutionOverlayResult and the ApexExecutionOverlayAction that caused it.
You could probably use a combination of Namespace
, ClassName
, Line
and UserId
to retrieve a
ApexExecutionOverlayResult for the associated ApexExecutionOverlayAction. Since you can only have one checkpoint per line this should return a unique result. Note that some of these fields don't appear in the online documentation, but you can query them.
Attribution to: Daniel Ballinger
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/30758