diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ActionExecutionSolutionCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ActionExecutionSolutionCEImpl.java index 38c8664141d0..794d24af0b98 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ActionExecutionSolutionCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ActionExecutionSolutionCEImpl.java @@ -252,17 +252,24 @@ private Mono populateExecuteActionDTO(ExecuteActionDTO execute Mono systemInfoPopulatedExecuteActionDTOMono = actionExecutionSolutionHelper.populateExecuteActionDTOWithSystemInfo(executeActionDTO); - return systemInfoPopulatedExecuteActionDTOMono.flatMap( - populatedExecuteActionDTO -> Mono.zip(instanceIdMono, defaultTenantIdMono) - .map(tuple -> { - String instanceId = tuple.getT1(); - String tenantId = tuple.getT2(); - populatedExecuteActionDTO.setActionId(newAction.getId()); - populatedExecuteActionDTO.setWorkspaceId(newAction.getWorkspaceId()); - populatedExecuteActionDTO.setInstanceId(instanceId); - populatedExecuteActionDTO.setTenantId(tenantId); - return populatedExecuteActionDTO; - })); + return systemInfoPopulatedExecuteActionDTOMono.flatMap(populatedExecuteActionDTO -> Mono.zip( + instanceIdMono, defaultTenantIdMono) + .map(tuple -> { + String instanceId = tuple.getT1(); + String tenantId = tuple.getT2(); + populatedExecuteActionDTO.setActionId(newAction.getId()); + populatedExecuteActionDTO.setWorkspaceId(newAction.getWorkspaceId()); + if (TRUE.equals(executeActionDTO.getViewMode())) { + populatedExecuteActionDTO.setDatasourceId( + newAction.getPublishedAction().getDatasource().getId()); + } else { + populatedExecuteActionDTO.setDatasourceId( + newAction.getUnpublishedAction().getDatasource().getId()); + } + populatedExecuteActionDTO.setInstanceId(instanceId); + populatedExecuteActionDTO.setTenantId(tenantId); + return populatedExecuteActionDTO; + })); } /**