+ Start a Discussion

Percent of Apex Used: XX.XX% in salesforce

Hi I Want to get "Percent of Apex Used: XX.XX% " and need to send email at perticular level.

Can you please help on this?

Below queries are using for getting but not able to get correct result(These are tooling api objects).

1. SELECT Sum(LengthWithoutComments) FROM ApexClass WHERE ID NOT IN (SELECT ApexTestClassId FROM ApexCodeCoverage)
2. SELECT Sum(LengthWithoutComments) FROM ApexTrigger

I am doing sum of these two result.((Sum(1+2)/10000000)*100)

Ankit AroraAnkit Arora
Not sure but I don't think there is any way to do this even with Tooling API. What are the exact results you are getting from these queries?

Are you sure, this query is working. Also can you please explain from where did you get the field " Sum(LengthWithoutComments)". As you have mentioned this is a Tooling API objects, we cannot use this as normal objects. However, in workbench we have an option to quesry this REST Explorer, but in general you have to create your own application to use this Tooling API objects. Below mentioned link will provide you more information on how to query using workbench.


I hope this helped you.