diff --git a/x-pack/plugins/actions/server/builtin_action_types/servicenow/lib/index.ts b/x-pack/plugins/actions/server/builtin_action_types/servicenow/lib/index.ts index 1acb6c563801..cc07a0b90330 100644 --- a/x-pack/plugins/actions/server/builtin_action_types/servicenow/lib/index.ts +++ b/x-pack/plugins/actions/server/builtin_action_types/servicenow/lib/index.ts @@ -147,7 +147,14 @@ class ServiceNow { comments: Comment[], field: string ): Promise { - const res = await Promise.all(comments.map(c => this.createComment(incidentId, c, field))); + // Create comments sequentially. + const promises = comments.reduce(async (prevPromise, currentComment) => { + const totalComments = await prevPromise; + const res = await this.createComment(incidentId, currentComment, field); + return [...totalComments, res]; + }, Promise.resolve([] as CommentResponse[])); + + const res = await promises; return res; } diff --git a/x-pack/plugins/case/server/routes/api/cases/get_case.ts b/x-pack/plugins/case/server/routes/api/cases/get_case.ts index e947118a39e8..ac32b20541a9 100644 --- a/x-pack/plugins/case/server/routes/api/cases/get_case.ts +++ b/x-pack/plugins/case/server/routes/api/cases/get_case.ts @@ -40,6 +40,10 @@ export function initGetCaseApi({ caseService, router }: RouteDeps) { const theComments = await caseService.getAllCaseComments({ client, caseId: request.params.case_id, + options: { + sortField: 'created_at', + sortOrder: 'asc', + }, }); return response.ok({