function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Dan Albrecht 5Dan Albrecht 5 

Impact analysis

Have a very seasoned org and doing impact analysis is sometimes hit or miss. Does anyone know of a tool (or can provide a code example for a .net application using the tooling API) that will analyze where a field is being used or referenced?  This would allow us to pinpoint where to look or where other changes need to be made. Thanks in advance. 
Alain CabonAlain Cabon
Hi,

Is it a standard or a custom field for the impact analysis ? 

For a custom field, we can have a quite precise answer (simulating the deletion of the field) but for the standard fields (impossible to delete), it is just often a search by name globablly (all the fields Name in the org) for the existing tools (not precise).

1) Deepfield: tooling api called from Apex

//Get formula fields where field is used
//Get apex classes where field is used
//Get layouts where field is used

https://github.com/regularcoder/deepfield/blob/master/classes/DeepFieldController.cls

String response = getHTTP('/services/data/v37.0/tooling/search/?q=FIND+{' + currentobject + '+AND+' + currentfield + '}+IN+ALL+FIELDS+RETURNING+ApexClass+(Name)');

=> so it is not precise because if a class just constains the words "ACCOUNT" and "NAME", we consider that the field ACOUNT.NAME is used by the class. That is necessary but not sufficient and all the tools are doing the same things

2) Salesforce Toolkit: http://sftoolkit.co/
Welcome to the Salesforce Toolkit! The tools and applications below provide assistance for common consulting processes and tasks - from diagnosing your org, comparing environments to activating and deactivating Salesforce components.

Salesforce Schema Lister: http://schemalister.herokuapp.com/
This tool uses the Salesforce Metadata API to build a list of objects, fields and field attributes from within your Salesforce Org.
None of your organisation information or data is captured or kept from running this tool.

Schema Lister is interesting but not enough accurate for the impact analysis (use the same algorithm as above).

3) Reading the exported metadata (xml files): I wrote many (huge) Xquery requests for my own needs.

4) Parsing all the code with the PDM parser. It is the way where I am going now but it is complicated (in progress as we said).

https://github.com/Up2Go/pmd/tree/master/pmd-apex

https://salesforce.stackexchange.com/questions/1003/grammar-for-creating-an-apex-parser

Robert Sösemann:(Germany, Stuttgart) Certified Platform Developer II, Creator of #PMD for Apex + #ApexMetrics
https://github.com/up2go-rsoesemann

He managed to parse the apex code without having the complete formal grammar (not published) using the included "official" parser of Salesforce from the Eclipse Force IDE (as a "black box"). 

I have already spent hours to understand how I can use this tool now but it is a very timeconsuming work and fortunately, there is already the Robert Sösemann's result.

Alain
Alain CabonAlain Cabon
Hi,

Another interesting tool: sfdcCommander​
https://github.com/jwiesel/sfdcCommander

"He" (anonymous project but that could be Jonas Wiesel (Switzerland)  https://github.com/wieseljonas ) transforms almost all the xml files of the metadata with XSLT into HTML: https://github.com/jwiesel/sfdcCommander/tree/master/sfdcCommander/config/transformer

I prefer Xquery requests and the impressive BaseX tool (German): http://basex.org/about-us/
Dr. Christian Grün is member of the W3C XML Query Working Group. He contributes to the XQuery Full-Text Recommendation as Invited Expert.

With some "big" Xquery requests (for all the layouts with the translations French/English), I managed to "mix" almost all the main data of all the XML files of the exported metadata in the minute (1~45 seconds for each request) + primeUI widgets + bootstrap for a "nice" result.
 
Alain CabonAlain Cabon
For parsing the Apex code, you need the help of someone really very "strong" like Nick Chen alias vazexqi.

https://github.com/forcedotcom/idecore/issues/167

https://github.com/vazexqi
 
Alain CabonAlain Cabon
Like everything could become more and more "dynamics", the cross references of variables are really very difficult to do.

Currently, I got almost "all" the variables and the raw SOQL queries parsing the Apex code (basic parsing with the apex-jorge) but I have abandoned this work.

Officially, we should only use the symbol tables : 

Use symbol tables instead of building a parser or compiler.
Symbol tables allow you to do symbol highlighting, code navigation, code completion, symbol searches, and more.
A symbol table can’t be created if the content referenced by the ContentEntityId field doesn’t use a symbol table.
Compiler errors for the last deployment of the MetadataContainer in the MetadataContainerId field also prevent a symbol table from being created.

https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/tooling_api_objects_symboltable.htm

But there are "only" the interfaces, the signatures of the methods and constructors and the class variables. I don't think you can get the used SOQL queries and above all their fields with the symbol tables (must be confirmed).
FieldPro AdminFieldPro Admin
Try FieldPro (https://appexchange.salesforce.com/appxListingDetail?listingId=a0N3A00000EcsCZUAZ). This lightweight application enables Salesforce users to search/report/run-impact-analysis/find-metadata-references in all fields with lightning speed.
 
Candy Weekes 1Candy Weekes 1
I know it has been a while.  Did you find a good impact analysis software?  We are evaluating Panaya Foresight (https://www.panaya.com/product/salesforce-foresight/) and Elements Cloud (https://appexchange.salesforce.com/appxListingDetail?listingId=a0N3A00000EJicYUAT).  
Dan Albrecht 5Dan Albrecht 5
Actually we did.  We are using Strongpoint (https://strongpoint.io/).  We tried Gearset but the toolset was not robust enough and because of the age and size of our org, could not gather all the metadata needed to do full comparisions.  So far, we are ok with Strongpoint.  I would not say we are 100% happy but we are helping them to improve the platform so it ends up being a win win.  
Candy Weekes 1Candy Weekes 1
Thanks Dan :-).