Tableau API Uncatch (in promise) Exception$ {_message: "Parameter cannot be null or empty: fieldName



希望这里的人能帮我弄清楚为什么我会收到这个错误消息。我一直在用React Hooks将一个类组件重构为一个函数组件,我几乎在每一行都做了console.log((,以确保我返回的值与原始代码相同。控制台中的所有内容都匹配,直到我进入异步等待部分,控制台指示我遇到"Parameter cannot be null or empty:fieldName"问题。有人有什么想法吗?TIA!(顺便说一句,我知道这里有很多代码要显示,但因为只有当你登录我们的VPN时才能访问仪表板,我不知道有什么更好的方式来显示代码。(

const Categorical = () => {
let viz = useSelector(state => state.fetchDashboard);
const filterSelect = useSelector(state => state.fetchFilterSelect); 
let filterApplied = useSelector(state => state.fetchFilter);
const globalFilterTitles = ["Region", "Service Area", "Contract - Cohort"];
const globalFilters = useSelector(state => state.globalFilters)
const dispatch = useDispatch();
const selectedDashboard = useSelector(state => state.selectedDashboard);
const handleChange = (event, key, filterTitle) => {
let selectedValues = filterApplied;
let ind = event.target.value.indexOf("All");
if (filterSelect[key].indexOf("All") > -1) {
if (ind === -1) {
selectedValues[key] = [];
} else {
event.target.value.shift();
selectedValues[key] = event.target.value;
}
} else if (filterSelect[key].indexOf("All") > -1) {
if (ind > -1) {
selectedValues[key] = filterSelect[filterTitle];
} else if (
event.target.value.length + 1 ===
filterSelect[filterTitle].length
) {
selectedValues[key] = filterSelect[filterTitle];
} else {
selectedValues[key] = event.target.value;
}
} else selectedValues[key] = event.target.value;
console.log(selectedValues[key]);
return (
prevState => ({
...prevState,
filterApplied: selectedValues[key]
}),
async function () {
const values =
filterSelect[key].indexOf("All") > -1
? ""
: filterSelect[key];
const fType = values === "" ? "All" : "Replace";
let sheet = await viz
.getWorkbook()
.getActiveSheet()
.getWorksheets()
.get("Index");
sheet
.applyFilterAsync(filterTitle, values, fType)
.then(function () { })
.otherwise(function (err) {
alert(err);
});
let filterNames = {};
let filters = await sheet.getFiltersAsync();
for (let filter in filters) {
if (!isNaN(parseInt(filter))) {
if (
filters[filter].getFilterType() === "categorical" &&
filters[filter].getFieldName() !== "Measure Names" &&
filters[filter].getFieldName() !== "Measure Values" &&
filters[filter].getFieldName().search("_hide") < 0
) {
let filterTitle = filters[filter].getFieldName();
filterNames[filterTitle] = [];
console.log(filterNames[filterTitle])
let len = filters[filter].getAppliedValues().length;
if (
selectedDashboard.categoryForceSelect.indexOf(
filterTitle
) === -1 &&
len !== 0 &&
filterSelect[filterTitle].length - 1 === len
) {
filterNames[filterTitle].push("All");
}
for (let i = 0; i < len; i++) {
if (filters[filter].getAppliedValues()[i].value !== null) {
filterNames[filterTitle].push(
filters[filter].getAppliedValues()[i].value
);
}
}
}
}
}
fetchFilter(filterNames);
if (globalFilterTitles.indexOf(filterTitle) > -1) {
console.log(globalFilterTitles.indexOf(filterTitle));
//take previous value of filters
globalFilters[filterTitle] = filterNames[filterTitle]; // add new values to previous values
console.log(globalFilters);
setGlobalFilters(globalFilters);
} //update state with most recent values.
//Now whenever a new dashboard is requested, the most recent state of global filters will be applied.
}
);
};

我发现工作表.applyFilterAsync(filterTitle(值返回为未定义;当我把它改为在相应的地方键入时,它就如预期的那样工作了。

相关内容

  • 没有找到相关文章

最新更新