- 26 Jun 2023
- 2 Minutes to read
Creating Custom Salesforce Metadata Rules
- Updated on 26 Jun 2023
- 2 Minutes to read
After completing this unit, you'll be able to:
- Create a custom Salesforce metadata rule
- Adding Salesforce metadata types for the analysis
- Adding Salesforce metadata suffixes/extension for the analysis
Create a custom Salesforce metadata rule
This article explains how to create and enable the Salesforce Metadata rules in the CodeScan Cloud environment.
To enable downloading metadata for your Salesforce project, you will need to change some project settings. Remember that the following will only work with code being pulled from Salesforce.
Login to your CodeScan account.
Click on the
Quality profileson your main organization page and then click on
Create a new rule by selecting the language as
Salesforce Metadataand name your new profile. You can choose the
Parent ruleas an optional.
Once you create the new quality profile, you will be navigated to a new page where you need to click on
Activate Morebutton on the left.
Now, make sure on your left side of the page where you see the name of the rule you created; it is marked as inactive.
Make sure that you activate the four rules referenced below by clicking on the
Activatebutton beside the rule.
- Record Type ID is Missing
- Object Permissions should not be permissive
- Enforce Org Security Settings
- Custom fields must have a description field
Once activated, select the
Activebutton under filters (beside the rule’s name).
Adding Salesforce metadata types for the analysis
Once you are done with the activation of the custom rule, go to the project with the rules you wish to run the analysis, and click on
Project Settings > General settings.
CodeScantab on the left to open the CodeScan specific settings and access the
CodeScan Cloud Download Types.
The default values are ApexClass, ApexComponent, ApexPage, ApexTrigger, AuraDefinitionBundle, and LightningComponentBundle.
CodeScan is capable to analyze all metadata types supported by Metadata API of Salesforce. Refer to the Salesforce Developer API documentation to find the supported metadata types.
CodeScan Cloud Download Types, enter the Salesforce metadata types needed for the analysis, then select the
Adding Salesforce metadata suffixes/extensions for the analysis
CodeScansection, scroll down to
Scope, where you see
Metadata File Suffixes.
Add the suffixes for the files to analyze.
Point to Note:
Include your Salesforce metadata types for analysis under the
Project Settings > General Settings > CodeScan > CodeScan Cloud Download Typessection for your specific project. Later, add the relevant metadata types' suffixes/extension under the
Metadata File Suffixessection.
Refer to the Salesforce Developer API documentation to find the supported metadata types and their relevant suffixes/extension.
Run the analysis again by navigating to the
Project Settings > Project Analysismenu and selecting the
Run Manual Analysisbutton. If your metadata files contain issues, you will see that reflected in the issues list.
Make sure the line count will not show up on the line count breakdown as it is not a language. However, the issues will show up in the issues list as seen in the above figure.
Happy to Help
If you are still having trouble setting up metadata rules after reading the complete documentation, please contact the support team, and we'll be happy to help.