Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add WorkflowFlowActions metadata support #976

Closed

Conversation

mcarvin8
Copy link
Contributor

@mcarvin8 mcarvin8 commented Jan 8, 2025


I think we've talked about this previously in my plugin, but Workflow Flow Actions was missing in the Salesforce metadata registry. When opting into Salesforce's decomposed workflows, this caused my flow actions in my org to be decomposed in the parent file.

I recently contributed to SDR via forcedotcom/source-deploy-retrieve#1467 to add Workflow Flow Actions to the overall metadata registry and the decomposed workflows preset. This was accepted by Salesforce and looks to be on track to be in the next CLI release. This will require sfdx-git-delta to be updated to detect decomposed workflow flow actions when this update is released to the public.

Based on the open PR in https://github.com/forcedotcom/cli, this update will be included in the 2.72.21 (Jan 15, 2025) build.

Does this close any currently open issues?

No open issues but this will cause an issue if left unresolved once Salesforce CLI 2.72.21 is released and users attempt to use sfdx-git-delta to detect changes to decomposed workflow flow actions afterwards.

  • Jest tests added to cover the fix.
  • NUT tests added to cover the fix.
  • E2E tests added to cover the fix.

Any particular element that can be tested locally

You have existing decomposed tests already, not sure if you want to update/add this specific metadata type to the test or not. This is my first true contribution to sfdx-git-delta, so I'll leave the call up to you if you want me to add/update any tests for this metadata registry update.

Any other comments

Depends on Salesforce CLI release 2.72.21 (Jan 15, 2025) build. Probably want to release it around then to coincide with users using the latest available CLI.

@scolladon scolladon changed the title fix: add workflow flow actions feat: add workflow flow actions Jan 9, 2025
@scolladon scolladon changed the title feat: add workflow flow actions feat: add WorkflowFlowActions metadata support Jan 9, 2025
@scolladon
Copy link
Owner

Hi @mcarvin8 !

Thank you very much for this contribution.
That's very kind of view to anticipate the impact of your contribution elsewhere 🙏

First I'm not sure the fullName is the key. My guess is it could be label but I'm not able to check that for sure as I don't find examples of a flowActions xml definition and I'm not able to create it as I'm not part of the pilot...

Also, I don't understand why there is a pilot on Workflow as it will be deprecated soon.
I cannot event create a new WorkflowRule in my sandboxes 😅

In term of tests you can improve the inFileHandler.test.ts by adding the type here and by a on of the test to test this type in particular (just change the mockCompare.mockImplementation resolve and then the expect)

@mcarvin8
Copy link
Contributor Author

mcarvin8 commented Jan 9, 2025

image

Here's an example of a flow action which does have the fullName key. Not sure why the doc doesn't have it, but I'm guessing it's stale since this was a pilot.

I understand it definitely is weird for them to have this now that workflows are deprecated, but in my org and with the current decomposed workflow preset, I was unable to deploy individual workflow children like Email Alerts with the workflows that had workflow flow actions since those flow actions were in the parent XML file.

It seems like the decomposed workflow preset by Salesforce works best when the parent XML file remains an empty file.

When I manually updated the sfdx-project.json with a custom decompose workflow preset with flow actions to unblock me and create the file as shown in my screenshot, I was able to resolve my deployment issues and I was able to deploy the flow actions that are present in my org.

This is probably a small use case of users who may experience this issue (i.e. ones who have any flow actions) but if they an old large org like my work org, they might have the same issue as me.

  "registryCustomizations": {
    "childTypes": {
      "workflowalert": "workflow",
      "workflowfieldupdate": "workflow",
      "workflowknowledgepublish": "workflow",
      "workflowoutboundmessage": "workflow",
      "workflowrule": "workflow",
      "workflowsend": "workflow",
      "workflowtask": "workflow",
      "workflowflowaction": "workflow"
    },
    "strictDirectoryNames": {
      "workflows": "workflow"
    },
    "suffixes": {
      "workflow": "workflow"
    },
    "types": {
      "workflow": {
        "children": {
          "directories": {
            "workflowAlerts": "workflowalert",
            "workflowFieldUpdates": "workflowfieldupdate",
            "workflowKnowledgePublishes": "workflowknowledgepublish",
            "workflowOutboundMessages": "workflowoutboundmessage",
            "workflowRules": "workflowrule",
            "workflowSends": "workflowsend",
            "workflowTasks": "workflowtask",
            "workflowFlowActions": "workflowflowaction"
          },
          "suffixes": {
            "workflowAlert": "workflowalert",
            "workflowFieldUpdate": "workflowfieldupdate",
            "workflowKnowledgePublish": "workflowknowledgepublish",
            "workflowOutboundMessage": "workflowoutboundmessage",
            "workflowRule": "workflowrule",
            "workflowSend": "workflowsend",
            "workflowTask": "workflowtask",
            "workflowFlowAction": "workflowflowaction"
          },
          "types": {
            "workflowalert": {
              "directoryName": "workflowAlerts",
              "id": "workflowalert",
              "name": "WorkflowAlert",
              "suffix": "workflowAlert",
              "xmlElementName": "alerts"
            },
            "workflowfieldupdate": {
              "directoryName": "workflowFieldUpdates",
              "id": "workflowfieldupdate",
              "name": "WorkflowFieldUpdate",
              "suffix": "workflowFieldUpdate",
              "xmlElementName": "fieldUpdates"
            },
            "workflowknowledgepublish": {
              "directoryName": "workflowKnowledgePublishes",
              "id": "workflowknowledgepublish",
              "name": "WorkflowKnowledgePublish",
              "suffix": "workflowKnowledgePublish",
              "xmlElementName": "knowledgePublishes"
            },
            "workflowoutboundmessage": {
              "directoryName": "workflowOutboundMessages",
              "id": "workflowoutboundmessage",
              "name": "WorkflowOutboundMessage",
              "suffix": "workflowOutboundMessage",
              "xmlElementName": "outboundMessages"
            },
            "workflowrule": {
              "directoryName": "workflowRules",
              "id": "workflowrule",
              "name": "WorkflowRule",
              "suffix": "workflowRule",
              "xmlElementName": "rules"
            },
            "workflowsend": {
              "directoryName": "workflowSends",
              "id": "workflowsend",
              "name": "WorkflowSend",
              "suffix": "workflowSend",
              "xmlElementName": "send"
            },
            "workflowtask": {
              "directoryName": "workflowTasks",
              "id": "workflowtask",
              "name": "WorkflowTask",
              "suffix": "workflowTask",
              "xmlElementName": "tasks"
            },
            "workflowflowaction": {
              "directoryName": "workflowFlowActions",
              "id": "workflowflowaction",
              "name": "WorkflowFlowAction",
              "suffix": "workflowFlowAction",
              "xmlElementName": "flowActions"
            }
          }
        },
        "directoryName": "workflows",
        "id": "workflow",
        "inFolder": false,
        "name": "Workflow",
        "strategies": {
          "adapter": "decomposed",
          "decomposition": "folderPerType",
          "transformer": "decomposed"
        },
        "strictDirectoryName": true,
        "suffix": "workflow"
      }
    }
  },

@mcarvin8
Copy link
Contributor Author

mcarvin8 commented Jan 9, 2025

I can work on updating the inFileHandler.test.ts for this

@mcarvin8
Copy link
Contributor Author

mcarvin8 commented Jan 9, 2025

Here's a CI pipeline example showing a successful pipeline push with the decompsoed flow action if you wanna see that. That's after updating the sfdx-project.json with the adjusted preset manually, which Salesforce showed me how to do that.

image

@mcarvin8 mcarvin8 force-pushed the fix/add-workflow-flow-actions branch 2 times, most recently from 94f748a to db23be8 Compare January 9, 2025 15:39
@scolladon
Copy link
Owner

I see your point @mcarvin8
Thanks for your time and explanation, nice talk.
I'm sold with the argument of large old repo having the feature 😄.

I'm a bit scared about the fullName key though, maybe we should valide that with our cli-friends slack channel.

Then we could just work on the unit tests

@mcarvin8
Copy link
Contributor Author

mcarvin8 commented Jan 9, 2025

Let me know if the test update is right. I just changed one of the tests with WorkflowAlert to WorkflowFlowAction , there's still several ones with the alert.

Tests pass locally on my end based on your contributing doc:

{8E67E71C-5D78-4395-B8FC-48C82BA68C89}

@scolladon
Copy link
Owner

Let me know if the test update is right. I just changed one of the tests with WorkflowAlert to WorkflowFlowAction , there's still several ones with the alert.

That is very fine, thank you @mcarvin8 !
That is exactly what I meant.

@mcarvin8
Copy link
Contributor Author

mcarvin8 commented Jan 9, 2025

If you wanna validate this with the cli-friends slack channel, go for it. I worked with Steve Hetzel in the SDR repo after I opened an issue in the main CLI issues repo.

Didn't know they had a slack channel for outside help lol

Here's what I had in their repos originally: (GitHub issue forcedotcom/cli#2563, source-deploy-retrieve PR forcedotcom/source-deploy-retrieve#1467)

Copy link
Owner

@scolladon scolladon left a comment

Choose a reason for hiding this comment

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

Great job !
Thanks for the contribution
I want to wait for the validation from sfdx about the key

@@ -82,7 +83,7 @@ describe.each([true, false])(`inFileHandler -d: %s`, generateDelta => {
// Assert
expect(work.diffs.destructiveChanges.size).toEqual(0)
expect(work.diffs.package.get('Workflow')).toEqual(new Set(['Account']))
expect(work.diffs.package.get('WorkflowAlert')).toEqual(
expect(work.diffs.package.get('WorkflowFlowAction')).toEqual(
Copy link
Owner

Choose a reason for hiding this comment

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

praises: nice

I think it is enough for the unit test

parentXmlName: 'Workflow',
xmlName: 'WorkflowFlowAction',
xmlTag: 'flowActions',
key: 'fullName',
Copy link
Owner

Choose a reason for hiding this comment

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

thought: I'd really like a validation from sfdx

@mcarvin8 mcarvin8 force-pushed the fix/add-workflow-flow-actions branch from db23be8 to 0b6a2ab Compare January 14, 2025 16:14
Copy link

codeclimate bot commented Jan 14, 2025

Code Climate has analyzed commit 0b6a2ab and detected 0 issues on this pull request.

View more on Code Climate.

@mcarvin8
Copy link
Contributor Author

Rebased from main and updated v63.json with these changes

Copy link

codecov bot commented Jan 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (769ce5f) to head (0b6a2ab).
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #976   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           44        44           
  Lines          990       990           
  Branches       103       103           
=========================================
  Hits           990       990           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@scolladon
Copy link
Owner

I @mcarvin8 !

I come for news, have you been able to see with the sf cli team if the fullName is set in the xml files, even if the documentation do not say so ?

@mcarvin8
Copy link
Contributor Author

@scolladon - I wasn't sure how to validate with CLI team, to be honest I thought you were checking lol

Looking at your earlier message about some slack channel, I'm not sure how to see that??

@scolladon
Copy link
Owner

scolladon commented Jan 16, 2025

My bad, I thought you wanted to interact with them.

Looking at your earlier message about some slack channel, I'm not sure how to see that??

There is a slack channel named cli-friends where we can discuss with the engineering team of the sf cli product
They share very good insight very quickly. I find it easier than creating a github issue for something that does not interest anyone else

Give me your email and I'll add you

@mcarvin8
Copy link
Contributor Author

@scolladon can you have Vivek please resend that slack invite to my work email instead? [email protected]

Having issues joining with my personal email so it might be easier just to use the work one which already is connected to slack.

@mcarvin8
Copy link
Contributor Author

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

Explains why my org can use flow actions. Whomever opted into the pilot program can still use them.

image

@mcarvin8
Copy link
Contributor Author

Here's a sample decomposed workflow flow action:

Based on this, looks like fullName is the API name and label is the name.

<?xml version="1.0" encoding="UTF-8"?>
<WorkflowFlowAction xmlns="http://soap.sforce.com/2006/04/metadata">
    <fullName>Populate_PBA_from_Primary_CDM_User_record</fullName>
    <flow>Populate_Account_PBA_from_Primary_CDM_User_record</flow>
    <flowInputs>
        <name>AccountID</name>
        <value>{!Id}</value>
    </flowInputs>
    <flowInputs>
        <name>AccountOwner</name>
        <value>{!CDM__r.Id}</value>
    </flowInputs>
    <label>Populate PBA from Primary CDM User record</label>
    <language>en_US</language>
    <protected>false</protected>
</WorkflowFlowAction>

@scolladon
Copy link
Owner

Here's a sample decomposed workflow flow action:

Based on this, looks like fullName is the API name and label is the name.

<?xml version="1.0" encoding="UTF-8"?>
<WorkflowFlowAction xmlns="http://soap.sforce.com/2006/04/metadata">
    <fullName>Populate_PBA_from_Primary_CDM_User_record</fullName>
    <flow>Populate_Account_PBA_from_Primary_CDM_User_record</flow>
    <flowInputs>
        <name>AccountID</name>
        <value>{!Id}</value>
    </flowInputs>
    <flowInputs>
        <name>AccountOwner</name>
        <value>{!CDM__r.Id}</value>
    </flowInputs>
    <label>Populate PBA from Primary CDM User record</label>
    <language>en_US</language>
    <protected>false</protected>
</WorkflowFlowAction>

That is great, thanks for digging this @mcarvin8

Can you show the content of the workflow file when it is not decomposed please ?
Just to make sure (I'm 100% sure) it is in the file as well.

@mcarvin8
Copy link
Contributor Author

@scolladon - here's a screenshot from the original workflow file not decomposed.

image

   <flowActions>
        <fullName>Populate_PBA_from_Primary_CDM_User_record</fullName>
        <flow>Populate_Account_PBA_from_Primary_CDM_User_record</flow>
        <flowInputs>
            <name>AccountID</name>
            <value>{!Id}</value>
        </flowInputs>
        <flowInputs>
            <name>AccountOwner</name>
            <value>{!CDM__r.Id}</value>
        </flowInputs>
        <label>Populate PBA from Primary CDM User record</label>
        <language>en_US</language>
        <protected>false</protected>
    </flowActions>

@mcarvin8 mcarvin8 deleted the fix/add-workflow-flow-actions branch January 23, 2025 16:14
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.

2 participants