Script for getting document approval results

This is article provides an example of a script for getting the approval result comment. The script uses context variables:
context.Doc - variable of the Contract type
context.Comment - variable of the Text type
For the script to work, add the following assemblies:
Elewise.ELMA.Documents
Elewise.ELMA.Documents.Docflow
Namespaces:
using EleWise.ELMA.Documents.Managers;
using EleWise.ELMA.Documents.Models;
using EleWise.ELMA.Documents.Models.Tasks;
using EleWise.ELMA.Extensions;
using EleWise.ELMA.Model.Managers;
 
Script text:
var harm=ApprovementTaskGroupManager.Instance.GetGroupsByDocument(context.Doc); //get all the approval tasks of this document
                context.Comment = "";
            foreach(var i in harm.ToList())
            { 
                 
                foreach(var j in i.ApprovementList.Items.ToList())
                {
                    foreach(var res in j.Results.ToList())
                    {
                        context.Comment+= res.Item.User.FullName + " " + res.Item.SolutionDate + "\n"; 
                        foreach (var cm in res.Item.Comment.ToList())
                        {
                            context.Comment+= cm.ToString();
                        }
                                        context.Comment+= "\n";
                    }
                }
            }
 
 
Creating a similar script with PublicAPI
Documentation on PublicAPI is available here
var harm = PublicAPI.Docflow.Tasks.GetApprovementGroupsByDocument(context.Doc); //get all the approval tasks of this document
context.Comment = "";
foreach(var i in harm.ToList())
{ 
                  
    foreach(var j in i.ApprovementList.Items.ToList())
    {
        foreach(var res in j.Results.ToList())
        {
            context.Comment+= res.Item.User.FullName + " " + res.Item.SolutionDate + "\n"; 
            foreach (var cm in res.Item.Comment.ToList())
            {
                context.Comment+= cm.ToString();
            }
            context.Comment+= "\n";
        }
    }
}