var oDocument = Api.GetDocument();
var aForms = oDocument.GetAllForms();
var sKeys = [];
aForms.forEach(aForm => {
    sKeys.push(aForm.GetFormKey());
});
var json = JSON.stringify(sKeys);
GlobalVariable["json"] = json;
builder.CloseFile();

builder.CreateFile("docx");
var json = GlobalVariable["json"];
var oDocument = Api.GetDocument();
var oParagraph = oDocument.GetElement(0);
oParagraph.AddText(json);
oDocument.Push(oParagraph);
Api.Save();
builder.SaveFile("txt", "keys.txt");
builder.CloseFile();
