From bf46ae6aa8861523c7cdcf7febaa0dd36979db3f Mon Sep 17 00:00:00 2001 From: Daniel Ventura Date: Mon, 5 Dec 2022 10:23:17 +0000 Subject: [PATCH] #299 changing logic so it gets all the result ids from the jobExceptionId --- .../classes/mcdo_RunCopadoFunctionFromLWC.cls | 15 ++++++++++----- .../lwc/mcdo_RetrieveTable/mcdo_RetrieveTable.js | 15 +++++++++------ 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/force-app/main/default/classes/mcdo_RunCopadoFunctionFromLWC.cls b/force-app/main/default/classes/mcdo_RunCopadoFunctionFromLWC.cls index 8a68d66..f6a82b1 100644 --- a/force-app/main/default/classes/mcdo_RunCopadoFunctionFromLWC.cls +++ b/force-app/main/default/classes/mcdo_RunCopadoFunctionFromLWC.cls @@ -133,19 +133,24 @@ public with sharing class mcdo_RunCopadoFunctionFromLWC { /** * This function calls returns the last resultId from the received jobExecution * @param jobExecutionId JobExecution Id from the jobExecution that we want to find the latest result id - * @return Returs the ID of the latest result created on the respective jobExecution + * @return Returs the list of IDs form the results created on the respective jobExecution */ @AuraEnabled - public static Id getResultId(String jobExecutionId) { + public static List getResultIds(String jobExecutionId) { // get the newest result associated with this job execution - copado__Result__c result = [ + copado__Result__c[] results = [ SELECT Id FROM copado__Result__c WHERE copado__JobStep__r.copado__JobExecution__c = :jobExecutionId WITH SECURITY_ENFORCED ORDER BY CreatedDate DESC - LIMIT 1 ]; - return result.Id; + List ids = new List(); + + for (copado__Result__c item : results) { + ids.add(item.Id); + } + + return ids; } } \ No newline at end of file diff --git a/force-app/main/default/lwc/mcdo_RetrieveTable/mcdo_RetrieveTable.js b/force-app/main/default/lwc/mcdo_RetrieveTable/mcdo_RetrieveTable.js index 33ebf9e..4dbbe6b 100644 --- a/force-app/main/default/lwc/mcdo_RetrieveTable/mcdo_RetrieveTable.js +++ b/force-app/main/default/lwc/mcdo_RetrieveTable/mcdo_RetrieveTable.js @@ -26,7 +26,7 @@ import { // Apex functions to retrieve Recorddata from LWC import ExecuteRetrieveFromCopado from "@salesforce/apex/mcdo_RunCopadoFunctionFromLWC.executeRetrieve"; import getMetadataFromEnvironment from "@salesforce/apex/mcdo_RunCopadoFunctionFromLWC.getMetadataFromEnvironment"; -import getResultId from "@salesforce/apex/mcdo_RunCopadoFunctionFromLWC.getResultId"; +import getResultIds from "@salesforce/apex/mcdo_RunCopadoFunctionFromLWC.getResultIds"; // "Commit Changes" Page Tab related import COMMIT_PAGE_COMMUNICATION_CHANNEL from "@salesforce/messageChannel/copado__CommitPageCommunication__c"; @@ -157,7 +157,7 @@ export default class mcdo_RetrieveTable extends LightningElement { showTable = false; refreshButtonDisabled = true; progressStatus = "Loading data"; - progressResultId = undefined; + currentResultIds = undefined; // Subscription related variables getProgressSubscription = {}; @@ -334,9 +334,9 @@ export default class mcdo_RetrieveTable extends LightningElement { * @returns {Promise} resolves when the job is done */ async subscribeToCompletionEvent(jobExecutionId) { - // getting the last result id with this jobExecution + // get result ID from Job step related to job execution try { - this.progressResultId = await getResultId({ jobExecutionId: jobExecutionId }); + this.currentResultIds = await getResultIds({ jobExecutionId: jobExecutionId }); } catch (error) { console.error(`ERROR STATUS: ${error.status} ${error.statusText}`); } @@ -345,8 +345,11 @@ export default class mcdo_RetrieveTable extends LightningElement { if (response.data.payload.copado__Progress_Status__c === "Refresh done") { this.unsubscribeThisSubscription(this.getProgressSubscription); this.progressStatus = "Completed!"; - } else if (response.data.payload.copado__ResultId__c === this.progressResultId) { - this.progressStatus = response.data.payload.copado__Progress_Status__c; + } else if ( + this.currentResultIds.includes(response?.data?.payload?.copado__ResultId__c) && + response?.data?.payload?.copado__Progress_Status__c + ) { + this.progressStatus = response?.data?.payload?.copado__Progress_Status__c; } };