Announcements
After writing a lot of TypeScript: form logic held in multiple files, I thought I would include all my common functions in a helper.ts file. Unfortunately, after importing it into a Form.ts file, I don't seem to get passed an intialisation error as shown below .
Setup
in my TS folder I have run (npm) installed : typscript, @types/node and @types/xrm . My event handler logic works fine if I attach the Form.ts to the form and call any function contained it.
MyProjectRootFolder\front-end\ts\src\code\utils\Helper.ts
// show a simple dialog export function displayPromptText(titleText : string, promptText : string) { let alertStrings = { confirmButtonLabel: "Ok", text:promptText, title: titleText }; var confirmOptions = { height: 400, width: 450 }; Xrm.Navigation.openAlertDialog(alertStrings, confirmOptions).then( function (success) { console.log("Dialog closed using OK button."); }, function (error) { console.log(error.message) } ) }
MyProjectRootFolder\front-end\ts\src\code\forms\MyForm.ts
import * as helper from "../utils/helper" // also tried this // import { displayPromptText } from "../utils/helper"; // if you call the line below say in Form load you get the intialisation error helper.displayPromptText("test","test");
Both Helper.ts and Form.ts transpile to JavaScript without issues. Whether I import all functions or a single function I don't get passed this error:
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
Congratulations to our community stars!
Expanding mentorship, skilling, and AI innovation
These are the community rock stars!
Stay up to date on forum activity by subscribing.
WarrenBelz 366 Most Valuable Professional
11manish 184
MS.Ragavendar 99 Super User 2026 Season 1