Last active
September 30, 2020 09:43
-
-
Save tugce/fd8e2d432f7c837c8693bde5debe1693 to your computer and use it in GitHub Desktop.
Unbundle stories for Copado USB. This code script can be run in the developer console to easily cancel the bundle for a specific bundle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Id bundleStoryId = 'BUNDLE_STORY_ID'; | |
//Get all the stories that are part of the bundle. | |
List<copado__User_Story__c> bundledStories = [SELECT Id, copado__Stop_Indexing_Metadata__c, copado__Exclude_From_CBM__c, Bundle_User_Story__c | |
FROM copado__User_Story__c | |
WHERE Is_Bundle__c = FALSE | |
AND Bundle_User_Story__c = :bundleStoryId]; | |
if(bundledStories.isEmpty()){ | |
//Nothing to do, let's return | |
return; | |
} | |
//Update fields to unbundle the stories | |
for(copado__User_Story__c cus : bundledStories){ | |
cus.Bundle_User_Story__c = null; | |
cus.copado__Stop_Indexing_Metadata__c = false; | |
cus.copado__Exclude_From_CBM__c = false; | |
} | |
update bundledStories; | |
//Update parent bundle status to cancelled | |
copado__User_Story__c bundle = [SELECT Id, copado__Status__c, copado__Cancellation_Reason__c | |
FROM copado__User_Story__c | |
WHERE Is_Bundle__c = TRUE | |
AND Id = :bundleStoryId]; | |
bundle.copado__Status__c = 'Cancelled'; | |
bundle.copado__Cancellation_Reason__c = 'Cancelled bundle'; | |
update bundle; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment