diff --git a/src/service/formConfig.js b/src/service/formConfig.js index 50aff9c0e4a5d95ec1f915e2be491862f71bdbaf..ceb69184e8ca67173319cb789775f9f10ee18851 100644 --- a/src/service/formConfig.js +++ b/src/service/formConfig.js @@ -47,35 +47,43 @@ async function read(req, response) { context_type: data.context_type, status: data.status || 'Active' } + console.log(query); await model.formdata.findOne({ where: query }).then(async data => { if (!data) { var temp = Object.assign({}, query, { channel: "*" }); + console.log(temp); // find record by specified rootOrgId with channel = '*' - await model.formdata.findOne({ where: temp }) + return await model.formdata.findOne({ where: temp }) } else { return data; } }) .then(async data => { if (!data) { + var temp = Object.assign({}, query, { objecttype: "*" }); + console.log(temp); // get the default data - return await model.formdata.findOne({ where: Object.assign({}, query, { objecttype: "*" })}) + return await model.formdata.findOne({ where: temp }) } else { return data; } }) .then(async data => { if (!data) { + var temp = Object.assign({}, query, { channel: "*", objecttype: "*" }); + console.log(temp); // get the default data - return await model.formdata.findOne({ where: Object.assign({}, query, { channel: "*", objecttype: "*" })}) + return await model.formdata.findOne({ where: temp }) } else { return data; } }) .then(async data => { if (!data) { + var temp = Object.assign({}, query, { channel: "*", objecttype: "*", primarycategory: "*" }); + console.log(temp); // get the default data - return await model.formdata.findOne({ where: Object.assign({}, query, { channel: "*", objecttype: "*", primarycategory: "*" })}) + return await model.formdata.findOne({ where: temp }) } else { return data; }