Last active
November 18, 2020 15:20
-
-
Save jdschleicher/d9f25d449316926862b1804fe88a0899 to your computer and use it in GitHub Desktop.
Bulk Agile Accelerator to Copado User Story Creation
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 agileAcceleratorScrumTeamCurrentSprintId = 'sprintidfromagileaccelerator'; | |
Id copadosScrumTeamProjectId = 'projectidfromcopado'; | |
Id copadosScrumTeamsDevOrgCredentialId = 'devorgidfromcopado'; | |
Id copadoReleaseId = 'releaseidfromcopado'; | |
List<agf__ADM_Work__c> agileAcceleratorWorkItems = [ | |
SELECT | |
agf__Age__c, | |
agf__Age_With_Scrum_Team__c, | |
agf__Age_With_Scrum_Team_When_Closed__c, | |
agf__Assignees__c, | |
agf__Type__c, | |
agf__Sprint_Name__c, | |
agf__Sprint__c, | |
agf__Origin__c, | |
agf__Parent_ID__c, | |
agf__Priority__c, | |
agf__Customer__c, | |
Name, | |
agf__Release__c, | |
agf__Subject__c, | |
agf__Status__c, | |
agf__Additional_Details__c, | |
agf__Details__c, | |
agf__Epic_Name__c, | |
agf__Priority_Rank__c, | |
agf__Related_URL__c, | |
agf__Related_URL_Link__c, | |
agf__Related_Work__c, | |
Id, | |
agf__Sprint__r.agf__Scrum_Team__r.agf__Kanban__c, | |
agf__Release__r.Name | |
FROM | |
agf__ADM_Work__c | |
WHERE agf__Sprint__c = :agileAcceleratorScrumTeamCurrentSprintId | |
]; | |
System.debug('here is the count of aa stories: ' + agileAcceleratorWorkItems.size()); | |
List<copado__User_Story__c> copadoUserStoriesToCreate = new List<copado__User_Story__c>(); | |
for (agf__ADM_Work__c aaWorkItem : agileAcceleratorWorkItems) { | |
copado__User_Story__c userStory = new copado__User_Story__c(); | |
userStory.copado__Project__c = copadosScrumTeamProjectId; | |
userStory.copado__Org_Credential__c = copadosScrumTeamsDevOrgCredentialId; | |
userStory.Agile_Accelerator_Story__c = aaWorkItem.Id; | |
userStory.copado__User_Story_Title__c = aaWorkItem.agf__Subject__c; | |
userStory.copado__Release__c = copadoReleaseId; | |
copadoUserStoriesToCreate.add(userStory); | |
} | |
insert copadoUserStoriesToCreate; | |
System.debug(' here are the stories created : ' + copadoUserStoriesToCreate); | |
String csv = 'Agile Accelerator Work Item ID, COPADO User Story ID\n'; | |
// String baseUrl = System.URL.getSalesforceBaseUrl().toExternalForm(); Do not have the correct permissions so hardcoding url | |
String baseUrl = 'https://vapm.lightning.force.com/'; | |
for (copado__User_Story__c createdUserStory : copadoUserStoriesToCreate) { | |
csv += (baseUrl + createdUserStory.Agile_Accelerator_Story__c) + ',' + (baseUrl + createdUserStory.Id) + '\n'; | |
} | |
ContentVersion file = new ContentVersion( | |
pathOnClient = ('AA-Copado-Relationships: ' + agileAcceleratorWorkItems[0].agf__Sprint_Name__c + '.csv'), | |
versionData = Blob.valueOf(csv) | |
); | |
insert file; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment