function createDataset(fields, constraints, sortFields) { var dataset = DatasetBuilder.newDataset(); dataset.addColumn("STATUS"); dataset.addColumn("CAMPO"); dataset.addColumn("VALOR"); try { dataset.addRow(["DEBUG", "__version__", "dsPortalFornecedorNF_debug_2026_03_12"]); if (!constraints || constraints.length === 0) { dataset.addRow(["DEBUG", "__constraints__", "vazio"]); return dataset; } for (var i = 0; i < constraints.length; i++) { var c = constraints[i]; var fieldName = getFieldNameSafe(c); var initialValue = getInitialValueSafe(c); dataset.addRow(["DEBUG", fieldName, initialValue]); } return dataset; } catch (e) { var erro = (e && e.message) ? e.message : ("" + e); dataset.addRow(["ERRO", "__exception__", erro]); return dataset; } } function getFieldNameSafe(c) { if (!c) return ""; if (typeof c.getFieldName === "function") return (c.getFieldName() || "") + ""; if (c.fieldName !== undefined && c.fieldName !== null) return (c.fieldName || "") + ""; return ""; } function getInitialValueSafe(c) { if (!c) return ""; if (typeof c.getInitialValue === "function") return (c.getInitialValue() || "") + ""; if (c.initialValue !== undefined && c.initialValue !== null) return (c.initialValue || "") + ""; return ""; }