Hi @martyg
,If my understanding is correct, you have a "Run checks" step in a scenario, and when the checks fail, you want to send the ID of each failed metric in a Microsoft Teams message.
You can accomplish this by using a custom variable in your Microsoft Teams reporter.
First, click "CREATE CUSTOM VARIABLES" in the reporter settings, and replace the code with the following code. This will create a custom variable called "${failedMetrics}" which will contain a list of failed metric IDs:
import json # compute your additional variables from the list of report items # and return them as a dictionary. def get_variables(items_json, scenario_run_json, step_run_output_json): step_run_output = json.loads(step_run_output_json) failed_metrics = [] # Iterate through all steps in the scenario and find # failed metric IDs for step in step_run_output.values(): for activity in step.values(): results = activity.get("results") if not results: continue for result in results: check = result.get("check") value = result.get("value") if not check or not value: continue metric_id = check.get("metricId") outcome = value.get("outcome") if not metric_id or not outcome: continue if outcome == "ERROR": failed_metrics.append(metric_id) return { "failedMetrics": ", ".join(failed_metrics) }
Now add the "${failedMetrics}" variable somewhere in your message template.
Thanks,
Zach
Sign up to take part
Registered users can ask their own questions, contribute to discussions, and be part of the Community!