diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/actioncollections/base/ActionCollectionServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/actioncollections/base/ActionCollectionServiceCEImpl.java index 12d3467b81..a613340e29 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/actioncollections/base/ActionCollectionServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/actioncollections/base/ActionCollectionServiceCEImpl.java @@ -638,18 +638,29 @@ public class ActionCollectionServiceCEImpl extends BaseService createJsAction(ActionCollection actionCollection, ActionDTO action) { ActionCollectionDTO collectionDTO = actionCollection.getUnpublishedCollection(); - // Make sure that the proper values are used for the new action - // Scope the actions' fully qualified names by collection name + + /** + * If the Datasource is null, create one and set the autoGenerated flag to true. This is required because spring-data + * cannot add the createdAt and updatedAt properties for null embedded objects. At this juncture, we couldn't find + * a way to disable the auditing for nested objects. + * + */ + if (action.getDatasource() == null) { + action.autoGenerateDatasource(); + } action.getDatasource().setWorkspaceId(collectionDTO.getWorkspaceId()); action.getDatasource().setPluginId(collectionDTO.getPluginId()); action.getDatasource().setName(FieldName.UNUSED_DATASOURCE); + + // Make sure that the proper values are used for the new action + // Scope the actions' fully qualified names by collection name action.setFullyQualifiedName(collectionDTO.getName() + "." + action.getName()); action.setPageId(collectionDTO.getPageId()); action.setPluginType(collectionDTO.getPluginType()); action.setDefaultResources(collectionDTO.getDefaultResources()); action.setApplicationId(actionCollection.getApplicationId()); - // Action doesn't exist. Create now. + // Action doesn't exist. Create now. NewAction newAction = newActionService.generateActionDomain(action); newAction.setUnpublishedAction(action);