Notifications
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.
In our never-ending quest to improve we are simplifying the forum hierarchy…
We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
WarrenBelz 721 Most Valuable Professional
Michael E. Gernaey 320 Super User 2025 Season 2
Power Platform 1919 268