Upadte field using validation rule function
Hi, i am trying to format phone field using validation rule, code works in workflow rule (tested), but i need to make this work inside validation rule function, since i already have tons of automation on workflow rule, and i would have problems if this automation run there..
My main problem, is that i dont know how to get DealID in validation rule, in workflow rule, we have "edit arguments" for that.. But in validation rule, we dont have it.. And i need dealID to update field.
see that line:
- dealId = entityMap.get("id");
This will not work, as it is not returned by crmAPIRequest
Se my code:
- entityMap = crmAPIRequest.toMap().get("record");
- decisor = entityMap.get("Whatsapp_Decisor");
- dealId = entityMap.get("id");
- responseMap = Map();
- // Remover todos os caracteres não numéricos do número de telefone
- whatsappformatado = decisor.replaceAll("[^0-9]","");
- // Verificar o comprimento do número
- length = whatsappformatado.length();
- // Verificar se o número tem 10 ou 11 dígitos e começa com "55"
- if(length == 10 && whatsappformatado.startsWith("55"))
- {
- // Adicionar "+55" e retornar o número formatado
- whatsappformatado = "+55" + whatsappformatado;
- }
- else if(length == 11 && whatsappformatado.startsWith("55"))
- {
- // Adicionar "+55" e retornar o número formatado
- whatsappformatado = "+55" + whatsappformatado;
- }
- else if(length >= 12 && length <= 13 && whatsappformatado.startsWith("55"))
- {
- // Remover o "55" extra e adicionar "+55" e retornar o número formatado
- whatsappformatado = "+55" + whatsappformatado.substring(2);
- }
- else
- {
- // Se não corresponder a nenhum padrão, assumir que é um número local e adicionar o código do país
- whatsappformatado = "+55" + whatsappformatado;
- }
- // Iniciar a criação do mapa
- mapUpdate = Map();
- // Definir o valor do campo "Whatsapp_Decisor" no mapa
- mapUpdate.put("Whatsapp_Decisor",whatsappformatado);
- // Atualizar o registro no Zoho CRM com o novo valor
- response = zoho.crm.updateRecord("Deals",dealId,mapUpdate);
- // Exibir a resposta da atualização e o número de telefone formatado
- responseMap.put("response",response);
- responseMap.put("whatsappformatado",whatsappformatado);
- return responseMap;
How to solve it? Anyone knows?
Thanks
Access your files securely from anywhere
Zoho Developer Community
Deliver unforgettable customer experiences
Deliver unforgettable customer experiences
New to Zoho Marketing Plus?
Everything you need to run your marketing
New to Zoho Marketing Plus?
Everything you need to run your marketing
Zoho Desk Resources
-
Desk Community Learning Series
-
-
-
-
-
-
-
-
-
Sticky Posts
Focus Group Webinar - Streamline Record Creation with Wizards
Hi there, With all the time your users spend on record creation, do you feel like they have the most seamless experience while doing it? For different types of records or those with a LOT of fields, do your users spend time navigating to enter data repeatedly?
Notes and Attachments visibility can now be restricted based on profiles
Dear All, We hope you're well! We are here with a quick update about Notes and Attachments profile permissions. In the past, a record's Notes and Attachments were visible by default to all users with record access. However, as notes and attachments can
Identify and prioritize profitable deals: Zoho CRM Forecasts help users focus on revenue-driving opportunities
Post moderated on: 7th November: Release update: This feature is now available for users in all DCs. Dear Customers, We hope you're well! At any given time, a sales rep handles multiple deals, each progressing at its own pace. But not all deals will succeed—some
Gain control over record sharing with portal users through our new enhancement: criteria-based data exposure
Dear Customers, We hope you're well! Portals is a self-service avenue through which your clients can access and manage their direct and related data in Zoho CRM. This empowers them to be more independent and enables them to experience a sense of transparency
Context and convenience just got better with Zia's email intelligence
Dear Customers, We hope you're well! We are in 2024, and email as a tool is only getting more powerful each day. While it enables seamless daily correspondences, we are here with a set of abilities that will enhance your user experience and save several
Zoho TeamInbox Resources
Zoho DataPrep Resources
Zoho CRM Plus Resources
Zoho Books Resources
Zoho Subscriptions Resources
Zoho Projects Resources
Zoho Sprints Resources
Qntrl Resources
Zoho Creator Resources
Zoho Campaigns Resources
Zoho CRM Resources
Zoho Show Resources
Writer Get Started. Write Away!
Writer is a powerful online word processor, designed for collaborative work.