hardis:project:fix:profiletabs
Description
Command Behavior
Interactively updates tab visibility settings in Salesforce profiles, addressing a common issue where tab visibilities are not correctly retrieved by sf project retrieve start.
This command provides a user-friendly interface to manage tab settings within your profile XML files, ensuring that your local project accurately reflects the intended tab configurations in your Salesforce org.
Key functionalities:
- Interactive Tab Selection: Displays a multi-select menu of all available tabs in your org, allowing you to choose which tabs to update.
- Visibility Control: Lets you set the visibility for the selected tabs to either
DefaultOn(Visible) orHidden. - Profile Selection: Presents a multi-select menu of all .profile-meta.xml files in your project, allowing you to apply the tab visibility changes to specific profiles.
- XML Updates: Modifies the
section of the selected profile XML files to reflect the chosen tab settings. If a tab visibility setting already exists for a selected tab, it will be updated; otherwise, a new one will be added. - Sorted Output: The
in the updated profile XML files are sorted alphabetically for consistency and readability.
Technical explanations
The command's technical implementation involves:
- SOQL Queries (Tooling API): It queries the
TabDefinitionobject usingsoqlQueryToolingto retrieve a list of all available tabs in the target org. - File Discovery: Uses
globto find all .profile-meta.xml files within the specified project path. - Interactive Prompts: Leverages the
promptslibrary to create interactive menus for selecting tabs, visibility settings, and profiles. - XML Parsing and Manipulation: Uses
parseXmlFileto read the content of profile XML files andwriteXmlFileto write the modified content back. It manipulates thetabVisibilitiesarray within the parsed XML to add or update tab settings. - Array Sorting: Employs the
sort-arraylibrary to sort thetabVisibilitiesalphabetically by tab name. - Logging: Provides feedback to the user about which profiles have been updated and a summary of the changes.
Parameters
| Name | Type | Description | Default | Required | Options |
|---|---|---|---|---|---|
| debug -d |
boolean | Activate debug mode (more logs) | |||
| flags-dir | option | undefined | |||
| json | boolean | Format output as json. | |||
| path -p |
option | Root folder | /home/runner/work/sfdx-hardis/sfdx-hardis | ||
| skipauth | boolean | Skip authentication check when a default username is required | |||
| target-org -o |
option | undefined | |||
| websocket | option | Websocket host:port for VsCode SFDX Hardis UI integration |
Examples
$ sf hardis:project:fix:profiletabs