Sharing a sample code through which we can Enable / Disable (turn on / turn off) multiple cloud flows using code.
E.g. here we want to turn on the below Cloud Flows owned by a specific user.

Table name – Workflow and Category – Modern Flow.

Below is the sample code, code is straightforward, we are updating the status of the record.
const string connectionString = "AuthType = ClientSecret; " +
"Url = https://[org].crm.dynamics.com/;" +
"ClientId=[GUID];" +
"ClientSecret=[Secret]";
var myServiceClient = new CrmServiceClient(connectionString);
if (myServiceClient.IsReady)
{
var query = new QueryExpression("workflow");
query.ColumnSet.AddColumns("workflowid", "name", "ownerid", "statecode", "category", "primaryentity", "solutionid");
// Category = 5 (Modern Flow)
query.Criteria.AddCondition("category", ConditionOperator.Equal, 5);
// owned by a specific user
query.Criteria.AddCondition("ownerid", ConditionOperator.Equal, "23d670c5-d02d-ee11-bdf4-0022482db7da");
var cloudFlows = myServiceClient.RetrieveMultiple(query);
foreach(var flow in cloudFlows.Entities)
{
var myFlow = new Entity("workflow", flow.Id);
// statecode = 1 (Turn On) and statecode = 0 (Turn Off)
myFlow.Attributes["statecode"] = new OptionSetValue(1);
myServiceClient.Update(myFlow);
}
}
The result :

Check Work with cloud flows using code.
Hope it helps..













