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

201
Visualizações
Chrome extension ExecuteScript not firing XRM JavaScript

Dynamics CRM has its own XRM JS APIs, Which I'm trying to execute in a chrome extension that I'm working on. I'm using the below code.

chrome.tabs.query({ currentWindow: true, active: true }, function(tabs) {
  chrome.scripting.executeScript({
    target: { tabId: tabs[0].id },
    func: () => {
      Xrm.Utility.alertDialog("Hello world", () => { });
    }
  });
});
Xrm.Utility.alertDialog("Hello world", () => { });

This code just shows a message box on the Dynamics CRM screen using this Dynamics API method.

If I run this code in the chrome console, it shows the message properly. If I just put alert("Hello world")", that code also runs which confirms that executeScript is working fine, but somehow Xrm isn't available.

Manifest.json enter image description here

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

0

After overflowing the stack a few times, I learned that the script injection needs to happen by explicitly creating a script tag and injecting it on the page body. similar to the code below.

function runOnXrmPage() {

    // create a script tag
    var s = document.createElement('script');
    s.src = chrome.runtime.getURL('webscript.js');
    s.onload = function () {
        this.remove();
    };
    (document.head || document.documentElement).appendChild(s);

}

chrome.tabs.query({ currentWindow: true, active: true }, function (tabs) {
            chrome.scripting.executeScript({
                target: { tabId: tabs[0].id },
                func: () => {
                    runOnXrmPage();
                }
            });
});


All the Xrm code was placed in webscript.js file and manifest was updated as pasted below.

  "web_accessible_resources": [
    {
      "resources": [ "webscript.js" ],
      "matches": [ "https://*.crm.dynamics.com/*" ]
    }
  ]
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