hello,
I have defined a "promise" and a "async function" as follows.
I made the fields validator definitions with await as follows.
The validation does not work correctly when using async property.
How can I fix this issue?
I have defined a "promise" and a "async function" as follows.
Code:
function getCategoryType(categoryTypeID) { return new Promise(resolve => { dsCategoryTypes.fetchData({ categoryTypeID: categoryTypeID, recordNumber: 1 }, function (dsResponse, data, dsRequest) { resolve(data[0] || null); }); }); } async function categoryTypeIsValid(item, validator, value, record) { var categoryType = await getCategoryType(record.categoryTypeID || null); if (categoryTypeID) { if (categoryTypeID.required === 1 && !value ) return false; } return true; }
Code:
isc.ListGrid.create({ fields: [ {name: "categoryType", type: "text", title: "Category Type" }, {name: "documentNumber", title: "Document Number", type: "text", validators: [ { type: "custom", errorMessage: "Document number is required", // when use async, validator don't work correctly condition: async function (item, validator, value, record) { var result = await CategoryTypeIsValid(item, validator, value, record); return result; } } ] } ] });
How can I fix this issue?
Comment