Many people wonder how to remove inactive versions flow and process builder.
I also had such a problem as the deployment went all over the branch and the versions accumulatedvery quickly especially on the integration environment.
Hope this helps you.
The URL is the address of your org.
Version restriction made to not touch the old versions.
You can upgrade the query as you like.
New version for removing flaw from the sandbox using an array.
Added a feature: do not delete the last N versions from the active version.
link
Execute Anonymous Window:
------
String soqlQuery = 'Select ID From Flow Where (Status = \'Obsolete\' OR Status = \'Draft\') AND VersionNumber > 1';
String orgUrl = URL.getSalesforceBaseUrl().toExternalForm();
HttpRequest flowIdRequest = new HttpRequest();
flowIdRequest.setMethod('GET');
flowIdRequest.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionId());
flowIdRequest.setEndpoint(orgUrl+'/services/data/v50.0/tooling/query?q=SELECT+id,status+FROM+Flow+Where+(+Status+=+\'Obsolete\'+OR+Status+=+\'Draft\'+)+AND+VersionNumber+>+1');
//flowIdRequest.setTimeout(120000);
Http http = new Http();
HttpResponse httpResponse = http.send(flowIdRequest);
List<Object> records = (List<Object>)((Map<String, Object>)JSON.deserializeUntyped(httpResponse.getBody())).get('records');
//get id
String[] ids = new List<String>();
for (Object variable : records) {
String str = variable.ToString();
String res = str.substringBefore(', Status');
res = res.substringAfter('Id=');
ids.add(res);
}
//delete
HttpRequest flowIdRequestDelete = new HttpRequest();
for (String idFlow : ids) {
flowIdRequestDelete.setMethod('DELETE');
flowIdRequestDelete.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionId());
flowIdRequestDelete.setEndpoint(orgUrl +'/services/data/v50.0/tooling/sobjects/Flow/'+idFlow);
Http http = new Http();
HttpResponse httpResponseDelete = http.send(flowIdRequestDelete);
}
------
bash script (using a file)
------
#!/bin/bash
org=$1
ver=$2
sfdx force:data:soql:query --query "Select ID From Flow Where (Status = 'Obsolete' OR Status = 'Draft') AND VersionNumber > $ver" --targetusername $org --usetoolingapi --resultformat csv > flowToDelete.csv
num=$(($(cat flowToDelete.csv | wc -l)-1))
numbase=$num
echo $numBase
while read c; do
if [[ "$c" != "Id" && "$c" != "Your query returned no results." ]]
then
sfdx force:data:record:delete --sobjecttype Flow --sobjectid $c --targetusername $org --usetoolingapi
num=$((num-1))
echo $num out of $numbase left
fi
done < flowToDelete.csv
rm flowToDelete.csv
------
https://github.com/d2269/SFScripts
The very best hand in Blackjack is a mix of an Ace with a 10-card or a face card. It cannot be crushed, except the vendor has the identical, which might be a Push, a tie. Blackjack, recognized as|also called|also referred to as} 21 considered one of the|is amongst the|is likely considered one of the} most popular on line casino card games in Las Vegas. The rules on playing in} blackjack in Vegas are quite easy, which is a major purpose for the sport's enduring popularity. Winning tactics in Blackjack require that the participant play every hand in the optimum means, and such technique all 1xbet the time takes into consideration what the vendor's upcard is.
ReplyDelete