Skip to content

Conversation

@k-capehart
Copy link
Contributor

Based on discussion here: https://github.com/Lightning-Flow-Scanner/lightning-flow-scanner-sfdx/discussions/89

Creates a new rule that scans for flows where Status != "Active"

Therefore an inactive flow would be any of the following: Draft, Obsolete, InvalidDraft: https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_visual_workflow.htm

@RubenHalman
Copy link
Member

RubenHalman commented May 7, 2024

This is awesome @k-capehart, thank you so much!

I would like to change the description in the rule (and also readme) to something a bit more elaborate, so heres some documentation I came across around this topic(which is limited):

  1. 'when testing flows that contain delete elements. Even if the flow is inactive, it triggers the delete operation.'
  2. 'while running a parent flow, it picks up the active version of the subflow attached to it. If no active version exsits for the subflow, then it executes the latest version of the subflow.'

In general I think inactive data is often recommended to be deleted so maybe it can be more generic.

I'll sleep on this, but this can be merged as is, its just an awesome job!

@nvuillam
Copy link
Contributor

nvuillam commented May 7, 2024

Great addition !

But... Inactive flows can be manually configured in the org and you won't see it in the sources 🥹

With sfdx hardis monitoring you'll see it and receive a notification on slack / teams / mail / api (grafana) 🥳

https://sfdx-hardis.cloudity.com/salesforce-monitoring-home/#detect-inactive-metadata

@RubenHalman
Copy link
Member

RubenHalman commented May 7, 2024

@nvuillam I tested this and if I deactivate a flow it changes the status when I retrieve the flow. So I am not sure what you mean exactly. According to the docs valid values are:

  • Active
    
  • Draft—In the UI, this status appears as Inactive.
    
  • Obsolete—In the UI, this status appears as Inactive.
    
  • InvalidDraft—In the UI, this status appears as Draft.
    

https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_visual_workflow.htm

@nvuillam
Copy link
Contributor

nvuillam commented May 7, 2024

@RubenHalman when you retrieve the flow yes, but after a deployment someone can manually create a new flow version and you won't see it :(

Copy link
Member

@RubenHalman RubenHalman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. The changes requested by me are not critical but would be appreciated. Additionally we need to update the readme with the new rule and its description, which I can take care of if you like.

@@ -0,0 +1,35 @@
import * as IdPrefixes from '../data/IdPrefixes.json';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@k-capehart this import can be removed


public execute(flow: core.Flow): core.RuleResult {
const inactiveFlows = [];
console.log(flow.name);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@k-capehart please remove the console log, it will show in the sfdx application

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, thanks so much for catching that! I'll update the PR

@RubenHalman
Copy link
Member

RubenHalman commented May 7, 2024

@nvuillam everything can be changed manually in production when it comes to a flow, so it should probably always be best practice to retrieve the source. It does really seem to be a seperate issue, and I think you also agree with the bottom-line of this PR, which is that having inactive flows in your Org is not in line with Best Practices?

@k-capehart
Copy link
Contributor Author

@RubenHalman I took a first pass at the description, but I'm sure you'll want to tweak it and link documentation. Thanks for the review!

@RubenHalman RubenHalman merged commit 9942539 into Flow-Scanner:master May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants