function createDataset(fields, constraints, sortFields) {
    var dataset = DatasetBuilder.newDataset();

    dataset.addColumn("C7_FILIAL");
    dataset.addColumn("C7_NUM");
    dataset.addColumn("C7_ITEM");
    dataset.addColumn("C7_PRODUTO");
    dataset.addColumn("C7_QUANT");
    dataset.addColumn("C7_PRECO");
    dataset.addColumn("C7_TOTAL");
    dataset.addColumn("C7_DATPRF");
    dataset.addColumn("C7_EMISSAO");
    dataset.addColumn("C7_NUMSC");
    dataset.addColumn("B1_DESC");
    dataset.addColumn("B1_UM");
    dataset.addColumn("B1_TIPO");

    try {
        var numeroPed = null;
        if (constraints) {
            for (var i = 0; i < constraints.length; i++) {
                if (constraints[i].fieldName == "numeroPed") {
                    numeroPed = constraints[i].initialValue;
                }
            }
        }

        var clientService = fluigAPI.getAuthorizeClientService();
        var data = {
            companyId: "1",
            serviceCode: "Postprod",
            endpoint: "/rest/uf_mata121", // sem número -> ele retorna todos
            method: "get",
            timeoutService: "60000"
        };

        var vo = clientService.invoke(JSON.stringify(data));
        if (vo && vo.getResult()) {
            var objData = JSON.parse(vo.getResult());
            var itens = objData["solicitacoes"];

            if (itens && itens.length > 0) {
                for (var i = 0; i < itens.length; i++) {
                    var item = itens[i];

                    // 🔎 se veio constraint, filtra pelo C7_NUM
                    if (numeroPed && item["C7_NUM"] != numeroPed) {
                        continue;
                    }

                    dataset.addRow([
                        item["C7_FILIAL"] || "",
                        item["C7_NUM"] || "",
                        item["C7_ITEM"] || "",
                        item["C7_PRODUTO"] || "",
                        item["C7_QUANT"] || "",
                        item["C7_PRECO"] || "",
                        item["C7_TOTAL"] || "",
                        item["C7_DATPRF"] || "",
                        item["C7_EMISSAO"] || "",
                        item["C7_NUMSC"] || "",
                        item["B1_DESC"] || "",
                        item["B1_UM"] || "",
                        item["B1_TIPO"] || ""
                    ]);
                }
            }
        }
    } catch (e) {
        dataset.addRow(["Erro: " + e.message]);
    }

    return dataset;
}
