From ebe4f901f7a1ad72c39cf1a4ecfb4c19e861a018 Mon Sep 17 00:00:00 2001 From: adriano Date: Mon, 13 Oct 2025 11:26:44 -0300 Subject: [PATCH] fix: implemented solution to solve lookup contact sap --- backend/utils/lookupCRMContactByPhone.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/backend/utils/lookupCRMContactByPhone.js b/backend/utils/lookupCRMContactByPhone.js index b59052d..42d7187 100644 --- a/backend/utils/lookupCRMContactByPhone.js +++ b/backend/utils/lookupCRMContactByPhone.js @@ -34,11 +34,14 @@ async function lookupContactByPhone(rest, authentication, crmPhone, companyId, t console.log("PAYLOAD CONFIG LOOKUP CONTACT BY PHONE CONFIG.url 1: ", config.url) - if(config.url.includes("+")){ - config.url = config.url.replace("+", "") - } + // Para consultar contato crm SAP, necessário consultar sem sinal de + no inicio numero + const pattern = /%2B\+/g; - console.log("PAYLOAD CONFIG LOOKUP CONTACT BY PHONE CONFIG.url 2: ", config.url) + if (pattern.test(config.url)){ + config.url = config.url.replace(/%2B\+/g, '%2B'); + } + + console.log("PAYLOAD CONFIG LOOKUP CONTACT BY PHONE CONFIG.url 2: ", config.url) console.log("PAYLOAD CONFIG LOOKUP CONTACT BY PHONE: ", JSON.stringify(config, null, 6))