Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

166
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!