From e2d971ebf5789e2e56a2a69b9fa482f9849ac2d1 Mon Sep 17 00:00:00 2001 From: ashish-egov <137176738+ashish-egov@users.noreply.github.com> Date: Tue, 18 Jun 2024 10:59:48 +0530 Subject: [PATCH] Update campaignMappingUtils.ts --- .../src/server/utils/campaignMappingUtils.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/utilities/project-factory/src/server/utils/campaignMappingUtils.ts b/utilities/project-factory/src/server/utils/campaignMappingUtils.ts index 32c4ad573cc..2dae20ea1fb 100644 --- a/utilities/project-factory/src/server/utils/campaignMappingUtils.ts +++ b/utilities/project-factory/src/server/utils/campaignMappingUtils.ts @@ -107,14 +107,14 @@ async function getProjectMappingBody(messageObject: any, boundaryWithProject: an if (boundaryWithProject[key]) { const resources: any[] = []; const pvarIds = getPvarIds(messageObject); - if (pvarIds) { + if (pvarIds && Array.isArray(pvarIds) && pvarIds.length > 0) { resources.push({ type: "resource", resourceIds: pvarIds }) } for (const type of Object.keys(boundaryCodes)) { - if (boundaryCodes[type][key]) { + if (boundaryCodes[type][key] && Array.isArray(boundaryCodes[type][key]) && boundaryCodes[type][key].length > 0) { resources.push({ type: type == "user" ? "staff" : type, resourceIds: [...boundaryCodes[type][key]] @@ -143,9 +143,12 @@ async function fetchAndMap(resources: any[], messageObject: any) { const boundaryCodes: any = {}; await enrichBoundaryCodes(resources, messageObject, boundaryCodes, sheetName); + logger.info("boundaryCodes : " + JSON.stringify(boundaryCodes)); var boundaryWithProject: any = {}; await enrichBoundaryWithProject(messageObject, boundaryWithProject, boundaryCodes); + logger.info("boundaryWithProject : " + JSON.stringify(boundaryWithProject)); const projectMappingBody = await getProjectMappingBody(messageObject, boundaryWithProject, boundaryCodes); + logger.info("projectMappingBody : " + JSON.stringify(projectMappingBody)); logger.info("projectMapping started "); const projectMappingResponse: any = await createCampaignService(projectMappingBody); logger.info("Project Mapping Response received");