diff --git a/src/Functions/Common/Get/Get.ts b/src/Functions/Common/Get/Get.ts
new file mode 100644
index 00000000..2f3f3dfb
--- /dev/null
+++ b/src/Functions/Common/Get/Get.ts
@@ -0,0 +1,56 @@
+/**
+ * @module Intacct/SDK/Functions/Common/Get
+ */
+
+/**
+ * Copyright 2021 Sage Intacct, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not
+ * use this file except in compliance with the License. You may obtain a copy
+ * of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * or in the "LICENSE" file accompanying this file. This file is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+import IaXmlWriter from "../../../Xml/IaXmlWriter";
+import AbstractFunction from "../../AbstractFunction";
+
+export default class Get extends AbstractFunction {
+ public object: string;
+ public key: string;
+ public fields: string[];
+
+ public writeXml(xml: IaXmlWriter): void {
+ if (this.object === undefined) {
+ throw new Error("required parameter 'object' undefined");
+ }
+ if (this.key === undefined) {
+ throw new Error("required parameter 'key' undefined");
+ }
+
+ xml.writeStartElement("function");
+ xml.writeAttribute("controlid", this.controlId, true);
+
+ xml.writeStartElement("get");
+ xml.writeAttribute("object", this.object);
+ xml.writeAttribute("key", this.key);
+
+ // optionally add fields to include in list
+ if (this.fields !== undefined) {
+ xml.writeStartElement("fields");
+ this.fields.forEach((field) => {
+ xml.writeElement("field", field);
+ });
+ xml.writeEndElement(); // fields
+ }
+
+ xml.writeEndElement(); // get_list
+
+ xml.writeEndElement(); // function
+ }
+}
diff --git a/src/Functions/Common/Get/index.ts b/src/Functions/Common/Get/index.ts
new file mode 100644
index 00000000..e5d2506c
--- /dev/null
+++ b/src/Functions/Common/Get/index.ts
@@ -0,0 +1 @@
+export { default as Get } from "./Get";
diff --git a/src/Functions/Common/GetList/GetList.ts b/src/Functions/Common/GetList/GetList.ts
index 1043ceb3..fd73938a 100644
--- a/src/Functions/Common/GetList/GetList.ts
+++ b/src/Functions/Common/GetList/GetList.ts
@@ -23,6 +23,8 @@ import AbstractFunction from "../../AbstractFunction";
export default class GetList extends AbstractFunction {
public object: string;
+ public fields: string[];
+
public writeXml(xml: IaXmlWriter): void {
xml.writeStartElement("function");
xml.writeAttribute("controlid", this.controlId, true);
@@ -30,6 +32,15 @@ export default class GetList extends AbstractFunction {
xml.writeStartElement("get_list");
xml.writeAttribute("object", this.object);
+ // optionally add fields to include in list
+ if (this.fields !== undefined) {
+ xml.writeStartElement("fields");
+ this.fields.forEach((field) => {
+ xml.writeElement("field", field);
+ });
+ xml.writeEndElement(); // fields
+ }
+
xml.writeEndElement(); // get_list
xml.writeEndElement(); // function
diff --git a/src/Functions/Common/index.ts b/src/Functions/Common/index.ts
index 28b6d93c..0a10a6ac 100644
--- a/src/Functions/Common/index.ts
+++ b/src/Functions/Common/index.ts
@@ -5,11 +5,8 @@ export { default as ReadMore } from "./ReadMore";
export { default as Inspect } from "../Common/Inspect";
export { default as Lookup } from "../Common/Lookup";
+import * as Get from "./Get/index";
import * as GetList from "./GetList/index";
import * as Query from "./Query/index";
import * as NewQuery from "./NewQuery/index";
-export {
- GetList,
- Query,
- NewQuery,
-};
+export { Get, GetList, Query, NewQuery };
diff --git a/test/Functions/Common/Get/GetTest.ts b/test/Functions/Common/Get/GetTest.ts
new file mode 100644
index 00000000..3f9527e2
--- /dev/null
+++ b/test/Functions/Common/Get/GetTest.ts
@@ -0,0 +1,70 @@
+/**
+ * Copyright 2020 Sage Intacct, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not
+ * use this file except in compliance with the License. You may obtain a copy
+ * of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * or in the "LICENSE" file accompanying this file. This file is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+import * as chai from "chai";
+import Get from "../../../../src/Functions/Common/Get/Get";
+import XmlObjectTestHelper from "../../../Xml/XmlObjectTestHelper";
+
+describe("Get", () => {
+ before((done) => {
+ return done();
+ });
+ beforeEach((done) => {
+ return done();
+ });
+ afterEach((done) => {
+ return done();
+ });
+ after((done) => {
+ return done();
+ });
+
+ it("should get supdoc (attachment)", () => {
+ const expected = `
+
+
+
+
+`;
+
+ const record = new Get("unittest");
+ record.object = "supdoc";
+ record.key = "A1234";
+
+ XmlObjectTestHelper.CompareXml(expected, record);
+ });
+
+ it("should get supdoc (attachment) fields", () => {
+ const expected = `
+
+
+
+
+ supdocid
+ description
+ folder
+
+
+
+`;
+
+ const record = new Get("unittest");
+ record.object = "supdoc";
+ record.key = "A1234";
+ record.fields = ["supdocid", "description", "folder"];
+
+ XmlObjectTestHelper.CompareXml(expected, record);
+ });
+});
diff --git a/test/Functions/Common/GetList/GetListTest.ts b/test/Functions/Common/GetList/GetListTest.ts
index 485060c6..5abc079d 100644
--- a/test/Functions/Common/GetList/GetListTest.ts
+++ b/test/Functions/Common/GetList/GetListTest.ts
@@ -30,6 +30,7 @@ describe("GetList", () => {
after((done) => {
return done();
});
+
it("should get company info", () => {
const expected = `
@@ -43,4 +44,25 @@ describe("GetList", () => {
XmlObjectTestHelper.CompareXml(expected, record);
});
+
+ it("should get company info fields", () => {
+ const expected = `
+
+
+
+
+ supdocname
+ description
+ folder
+
+
+
+`;
+
+ const record = new GetList("unittest");
+ record.object = "supdoc";
+ record.fields = ["supdocname", "description", "folder"];
+
+ XmlObjectTestHelper.CompareXml(expected, record);
+ });
});