Start and stop dataflows on command : Rikke
by: Rikke
blow post content copied from salesforceblogger.com
click here to view original post
When working with dataflows I think most of us simply schedule or manually run them to get new and fresh data (given the data sync has been updated). But guess what you can trigger the dataflow using APIs – so let’s see how we can do that with Salesforce CLI and Mohan’s plugin. If you haven’t used Mohan’s plugin before please check out this blog for details on how to install or update the plugin.
Note: this blog is using the following version sfdx-mohanc-plugins 0.0.131.
The dataflow start command
One of the main command for this blog is the dataflow start command. Let’s have a look at the options for the command by using the following:
sfdx mohanc:ea:dataflow:start -h

Let’s have a closer look on the option for this command.
Username
Use the -u option to specify a username to use for your command.
--The option sfdx mohanc:ea:dataflow:start -u <insert username> --Example sfdx mohanc:ea:dataflow:start -u [email protected]
Dataflow id
Use the -i option to specify a dataflow id to use for your command.
--The option
sfdx mohanc:ea:dataflow:start -u <insert username> -i <insert dataflow id>
--Example
sfdx mohanc:ea:dataflow:start -u [email protected] -i 02K3h000000MtyuEAC
The dataflow jobs stop command
The other main command for this blog is the dataflow jobs stop command. Let’s have a look at the options for the command by using the following:
sfdx mohanc:ea:dataflow:jobs:stop -h

Let’s have a closer look on the option for this command.
Username
Use the -u option to specify a username to use for your command.
--The option sfdx mohanc:ea:dataflow:jobs:stop -u <insert username> --Example sfdx mohanc:ea:dataflow:jobs:stop -u [email protected]
Dataflow job id
Use the -i option to specify a dataflow job id to use for your command.
--The option sfdx mohanc:ea:dataflow:jobs:stop -u <insert username> -i <insert dataflow job id> --Example sfdx mohanc:ea:dataflow:jobs:stop -u [email protected] -i 03CB000000383oAMAQ
The dataflow list command
To use the dataflow start command we need to have a dataflow id, which we can get by using the dataflow list command. To get the option for this command enter the following:
sfdx mohanc:ea:dataflow:list -h

Let’s have a closer look on the option for this command.
Username
Use the -u option to specify a username to use for your command.
--The option sfdx mohanc:ea:dataflow:list -u <insert username> --Example sfdx mohanc:ea:dataflow:list -u [email protected]
The dataflow jobs list command
To use the dataflow jobs stop command we need to have a dataflow job id, which we can get by using the dataflow job list command. To get the option for this command enter the following:
sfdx mohanc:ea:dataflow:jobs:list -h

Let’s have a closer look on the option for this command.
Username
Use the -u option to specify a username to use for your command.
--The option sfdx mohanc:ea:dataflow:jobs:list -u <insert username> --Example sfdx mohanc:ea:dataflow:jobs:list -u [email protected]
Start a dataflow
Okay, having covered the different commands let’s have a look at how we can start a dataflow using the Salesforce CLI.
Note: Before using the load command you would have to log in to the desired org by using the command sfdx force:auth:web:login, which will launch the login window in a browser.
Step 1 – use the dataflow:list command to find the list of dataflows and their ids.
sfdx mohanc:ea:dataflow:list
Step 2 – define the username for the target org by adding the -u option.
sfdx mohanc:ea:dataflow:list -u [email protected]
Step 3 – press enter.
Step 4 – in the list find the dataflow you want to start and copy the associated id.

Step 5 – use the dataflow:start command to start a dataflow
sfdx mohanc:ea:dataflow:start
Step 6 – define the username for the target org by adding the -u option.
sfdx mohanc:ea:dataflow:start -u [email protected]
Step 7 – define the dataflow id by adding the -i option. Use the id you copied in step 4.
sfdx mohanc:ea:dataflow:start -u [email protected] -i 02KB0000000nkUqMAI
Step 8 – press enter.
You will now get a message that your dataflow has been queued to run. You can always check the progress in the data monitor.


Stop a dataflow job
We just ran our dataflow, let’s say that was a mistake or maybe it’s been running too long and we want to stop the dataflow run. This we can also achieve with the Salesforce CLI. Let’s have a look at the steps to complete.
Note: Before using the load command you would have to log in to the desired org by using the command sfdx force:auth:web:login, which will launch the login window in a browser.
Step 1 – use the dataflow:jobs:list command to find the list of dataflows jobs and their ids.
sfdx mohanc:ea:dataflow:jobs:list
Step 2 – define the username for the target org by adding the -u option.
sfdx mohanc:ea:dataflow:jobs:list -u [email protected]
Step 3 – press enter.
Step 4 – in the list find the job you want to stop and copy the associated id.

Step 5 – use the dataflow:jobs:stop command to stop a dataflow.
sfdx mohanc:ea:dataflow:jobs:stop
Step 6 – define the username for the target org by adding the -u option.
sfdx mohanc:ea:dataflow:jobs:stop -u [email protected]
Step 7 – define the dataflow id by adding the -i option. Use the id you copied in step 4.
sfdx mohanc:ea:dataflow:jobs:stop -u [email protected] -i 03CB0000003DTAMMA4
Step 8 – press enter.
You will now get a message that your dataflow has been stopped. You can always confirm this in the data monitor.


January 19, 2021 at 07:26PM
Click here for more details...
=============================
The original post is available in salesforceblogger.com by Rikke
this post has been published as it is through automation. Automation script brings all the top bloggers post under a single umbrella.
The purpose of this blog, Follow the top Salesforce bloggers and collect all blogs in a single place through automation.
============================

Post a Comment