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

129
Visualizações
Automatically click the refresh button in Salesforce lightning

This is the code for the mentioned button that refreshes the selected salesforce view:

<div class="slds-button-group">
  <lightning-button-icon class="forceRefreshButton rotate">
    <button name="refreshButton" title="Refresh" type="button" class="slds-button slds-button_icon slds-button_icon-border-filled">
      <lightning-primitive-icon>
         <svg focusable="false" data-key="refresh" aria-hidden="true" viewBox="0 0 52 52" class="slds-button__icon">
          <g>
            <path d="M46.5 4h-3c-.8 0-1.5.7-1.5 1.5v7c0 .9-.5 1.3-1.2.7-.3-.4-.6-.7-1-1-5-5-12-7.1-19.2-5.7-2.5.5-4.9 1.5-7 2.9-6.1 4-9.6 10.5-9.7 17.5-.1 5.4 2 10.8 5.8 14.7 4 4.2 9.4 6.5 15.2 6.5 5.1 0 9.9-1.8 13.7-5 .7-.6.7-1.6.1-2.2l-2.1-2.1c-.5-.5-1.4-.6-2-.1-3.6 3-8.5 4.2-13.4 3-1.3-.3-2.6-.9-3.8-1.6C11.7 36.6 9 30 10.6 23.4c.3-1.3.9-2.6 1.6-3.8C15 14.7 19.9 12 25.1 12c4 0 7.8 1.6 10.6 4.4.5.4.9.9 1.2 1.4.3.8-.4 1.2-1.3 1.2h-7c-.8 0-1.5.7-1.5 1.5v3.1c0 .8.6 1.4 1.4 1.4h18.3c.7 0 1.3-.6 1.3-1.3V5.5C48 4.7 47.3 4 46.5 4z">
            </path>
          </g>
        </svg>
      </lightning-primitive-icon>
      <span class="slds-assistive-text">Refresh</span>
    </button>
  </lightning-button-icon>
</div>

The code I am using is:

setTimeout(autorefresh, 60000);
    
function autorefresh() {
      document.getElementsByClassName("forceRefreshButton").click();
        setTimeout(autorefresh, 60000);
    }
    
autorefresh();

The function should run every 60 seconds and click on the refresh view button. But it seems that I can't get the correct element.

Code overview:
Code overview

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

  1. Use setInterval(), so that the button is clicked repeatedly.
  2. .getElementsByClassName() returns an HTMLCollection, not an Element, therefore you can't call .click() on it.
  3. Call .click() on a button, .forceRefreshButton is not a <button> element.
function autorefresh() {
    document.querySelector('.forceRefreshButton > button').click();
}

setInterval(autorefresh, 60000);
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