Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

230
Visualizações
javascript: detect which variable changed its value

Given that I have the following condition to check whether a couple of variables value have changed.

<%
if (ctx.recipient.@firstName != ctx.recipient.@firstName_init || ctx.recipient.@lastName != ctx.recipient.@lastName_init || ctx.recipient.@emailPreferredName != ctx.recipient.emailPreferredName_init) 
    {       
        document.controller.setValue('/ctx/vars/piiChanges',1);     
    }
%>

How can I detect which of all the 3 conditions value changed?

Here is my XML payload

<recipient JOB_TITLE="" 
       blackListEmail="0" 
       cmOneID="0" 
       company="" 
       email="dummy@dummy.com1" 
       emailPreferredName="Dummy1" 
       firstName="Dummy1" 
       id="13246096" 
       initiative="" 
       investorType="" 
       jurisdiction="" 
       lastName="Dummy1" 
       lawfulBasisLabel="None" 
       lawfulBasisName="none" 
       leadScore="0" 
       origin="" 
       status="0" 
       statusLabel="Other" 
       statusName="other" 
       _operation="update" 
       _key="@id" 
       firstName_init="Dummy" 
       lastName_init="Dummy" 
       email_init="dummy@dummy.com" 
       emailPreferredName_init="Dummy" 
       blackListEmail_init="0">
<postalAddress addrDefined="0"/>
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You could loop through the data object's properties and get a list of all of the keys that have changed. Something like this:

function getChangedProperties(recipient) {
  const changedProps = [];

  // Loop over each of the property keys of the recipient object
  Object.keys(recipient).forEach(key => {
    // Check non-init values to see if their init counterparts are equal
    if (!key.endsWith("_init") && recipient[`${key}_init`] !== recipient[key]) {
      changedProps.push(key);
    }
  });

  return changedProps;
}
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda