Skip to main content

Has anyone found an easy way to pull the case close comments out of a case? It is buried in the JSON and the only way I can find (inconsistently) is some regex parsing

This comment was originally sent by Tom Fridman
@recon_acook You are right, there is no way to do this, only to use regular expression..
Here's a code snippet that might help
CLOSED_CASE_INFO_RE = "Case closed root cause: (.+?)\\nReason: (.+?)\\nComment: (.+?) \\n"

def getCaseClosureInfo(siemplify, caseId):
res = siemplify.session.get('{}/external/v1/cases/GetCaseFullDetails/{}'.format(siemplify.API_ROOT, caseId))
siemplify.validate_siemplify_error(res)
for comment in res.json()["wallData"]:
try:
if comment['activityKind'] == 9 and comment['description'].startswith("Case closed"):
rootCause, reason, comment = re.findall(CLOSED_CASE_INFO_RE, comment['description'])[0]
return {"rootCause": rootCause, "reason": reason, "comment": comment}
except KeyError:
pass


Thanks @Tomtomfridman ! That's better than the hacky way I had done it. Passed it on to our team
It would be very useful if the case close comment was available from CaseSearchEverything alongside isCaseClosed , rootCause , and closeReason .


@Tomtomfridman FYI, I had to change the regex to Case closed root cause: (.+?)\\nReason: (.+?)\\nComment: (.*) otherwise it was only grabbing the first letter of the comment for some reason? I'll keep messing with it and see if it's working everywhere


This comment was originally sent by Tom Fridman
Hi @recon_acook
Would you like to suggest that in our new ideas section ?