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

168
Visualizações
Dynamics 365 unable to reference javascript functions from exported typescript classes

I'm encountering an issue attempting to reference javascript functions from Dynamics 365 forms when the javascript files have been compiled from typescript that is exporting the class the function resides in (which I'm doing in order to run unit tests against them). The same problem does not occur if i put the function in a namespace instead, but it does if i then try to export the namespace instead/aswell as the function (again to be able to be reference in unit tests.

In each of the cases below, inside Dynamics in the onchange event I am referencing the function to be called by Referral.OpenDialogOnHold.

So when using:

export class Referral {
 static OpenDialogOnHold(context: Xrm.Events.EventContext) {
    try {
      Xrm.Navigation.navigateTo(
      ...
    );
    } catch (exception) {
      console.error(exception);
    }
  }
}

or

export namespace Referral {
 export function OpenDialogOnHold(context: Xrm.Events.EventContext) {
    try {
      Xrm.Navigation.navigateTo(
      ...
    );
    } catch (exception) {
      console.error(exception);
    }
  }
}

then it fails inside Dynamics saying it cannot find the function names Referral.OpenDialgOnHold

but if I use:

namespace Referral {
 export function OpenDialogOnHold(context: Xrm.Events.EventContext) {
    try {
      Xrm.Navigation.navigateTo(
      ...
    );
    } catch (exception) {
      console.error(exception);
    }
  }
}

then it works fine, however I'm then struggling to reference the function within unit tests as it complains the file is not a module.

Any assistance gratefully appreciated!

ts.config settings are:

{
  "compileOnSave": true,
  "compilerOptions": {
    "target": "ES5",
    "module": "ES2015",
    "rootDir": "ts",
    "moduleResolution": "node",
    "sourceMap": true,
    "outDir": "Webresources/ih_/js",
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "strict": true,
    "skipLibCheck": true
  },
  "exclude": ["tests/**/*"]
}
about 4 years ago · Juan Pablo Isaza
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