Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

227
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda