Comparing version 1.0.13 to 1.0.14
{ | ||
"name": "xrm-ex", | ||
"version": "1.0.13", | ||
"version": "1.0.14", | ||
"description": "Xrm-Ex is a TypeScript framework that simplifies the usage of Dynamics 365 Client API. It provides intuitive wrappers for formContext and Xrm Object, helping developers reduce the amount of code, increase maintainability, and decrease errors. Ideal for developers looking to leverage the power of Dynamics 365 Client API within the TypeScript ecosystem.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
122
README.md
@@ -19,3 +19,4 @@ # Xrm-Ex: Dynamics 365 Xrm Extensions | ||
## Getting Started | ||
To get started with XrmEx, you'll first need to reference the library in your **JavaScript** project and create an early bound fields Class. Create a variable which is going to hold the instance of your fields Class. Assign the executionContext OnLoad to XrmEx.Form.formContext and create a new instance of your fields class and you're good to go: | ||
To get started with XrmEx, use the Template below. Add XrmEx.js from your node_modules to your Dynamics 365 form as a library. Execute the method `YourNamespace.ContactFunctions.OnLoad` in your form and pass the executionContext to that function. | ||
Happy coding! | ||
@@ -27,62 +28,65 @@ > **Note:** Although built with TypeScript, this library is distributed as compiled javascript and its TypeScript declaration. This means it can be used in any **javascript** file by just referencing the `XrmEx.d.ts` file. For it to work, you have to add the `XrmEx.js` file to the Form in Dynamics 365. | ||
/// <reference path="node_modules/xrm-ex/src/XrmEx.d.ts" /> | ||
class Fields { | ||
Firstname = new XrmEx.TextField("firstname"); | ||
Customer = new XrmEx.LookupField("parentcustomerid"); | ||
DoNotEmail = new XrmEx.BooleanField("donotemail"); | ||
Birthday = new XrmEx.DateField("birthdate"); | ||
PreferredContactMethod = new XrmEx.OptionsetField( | ||
"preferredcontactmethodcode", | ||
{ | ||
Any: 1, | ||
Email: 2, | ||
Phone: 3, | ||
Fax: 4, | ||
Mail: 5, | ||
var YourNamespace = YourNamespace || {}; | ||
YourNamespace.ContactFunctions = { | ||
/**@type {Fields()}*/ fields: null, | ||
/**@type {Tabs()}*/ tabs: null, | ||
/**@type {Grids()}*/ grids: null, | ||
Fields: class Fields { | ||
Firstname = new XrmEx.TextField("firstname"); | ||
Customer = new XrmEx.LookupField("parentcustomerid"); | ||
DoNotEmail = new XrmEx.BooleanField("donotemail"); | ||
Birthday = new XrmEx.DateField("birthdate"); | ||
PreferredContactMethod = new XrmEx.OptionsetField( | ||
"preferredcontactmethodcode", | ||
{ | ||
Any: 1, | ||
Email: 2, | ||
Phone: 3, | ||
Fax: 4, | ||
Mail: 5, | ||
} | ||
); | ||
}, | ||
Tabs: class Tabs { | ||
General = new XrmEx.Tab("tab1", { | ||
Section1: new XrmEx.Section("section1"), | ||
Section2: new XrmEx.Section("section2"), | ||
}); | ||
Details = new XrmEx.Tab("tab2", { | ||
Section1: new XrmEx.Section("section1"), | ||
Section2: new XrmEx.Section("section2"), | ||
}); | ||
}, | ||
Grids: class Grids { | ||
ContactSubgrid = new XrmEx.GridControl("Test"); | ||
}, | ||
/** | ||
* @param {Xrm.FormContext | Xrm.Events.EventContext} executionContext | ||
*/ | ||
OnLoad: async function OnLoad(executionContext) { | ||
await this.Init(executionContext); //Ensures XrmEx is only accessed after the OnLoad Event | ||
try { | ||
fields.Firstname.Value = "Joe"; | ||
fields.Firstname.setVisible(false).setDisabled(false).setRequired(true); | ||
} catch (error) { | ||
console.error(error); | ||
await XrmEx.openAlertDialog("Error", `Error in ${XrmEx.getMethodName()}\n` + error.message); | ||
} | ||
); | ||
} | ||
class Tabs { | ||
General = new XrmEx.Tab("tab1", { | ||
Section1: new XrmEx.Section("section1"), | ||
Section2: new XrmEx.Section("section2"), | ||
}); | ||
Details = new XrmEx.Tab("tab2", { | ||
Section1: new XrmEx.Section("section1"), | ||
Section2: new XrmEx.Section("section2"), | ||
}); | ||
} | ||
class Grids { | ||
ContactSubgrid = new XrmEx.GridControl("Test"); | ||
} | ||
/** | ||
* @param {Xrm.FormContext | Xrm.Events.EventContext} executionContext | ||
*/ | ||
export async function Init(executionContext) { | ||
if (!XrmEx) { | ||
let errorMessage = "XrmEx is not loaded. Please make sure you have XrmEx.js loaded in your form."; | ||
console.error(errorMessage); | ||
await Xrm.Navigation.openAlertDialog({ title: "Error", text: errorMessage, }); | ||
return; | ||
}, | ||
/** | ||
* @param {Xrm.FormContext | Xrm.Events.EventContext} executionContext | ||
*/ | ||
Init: async function Init(executionContext) { | ||
if (!XrmEx) { | ||
let errorMessage = "XrmEx is not loaded. Please make sure you have XrmEx.js loaded in your form."; | ||
console.error(errorMessage); | ||
await Xrm.Navigation.openAlertDialog({ title: "Error", text: errorMessage, }); | ||
return; | ||
} | ||
XrmEx.Form.formContext = executionContext; | ||
fields = new this.Fields(); | ||
tabs = new this.Tabs(); | ||
grids = new this.Grids(); | ||
} | ||
XrmEx.Form.formContext = executionContext; | ||
fields = new Fields(); | ||
tabs = new Tabs(); | ||
grids = new Grids(); | ||
} | ||
/**@type {Fields()}*/ var fields; | ||
/**@type {Tabs()}*/ var tabs; | ||
/**@type {Grids()}*/ var grids; | ||
/** | ||
* @param {Xrm.FormContext | Xrm.Events.EventContext} executionContext | ||
*/ | ||
export async function OnLoad(executionContext) { | ||
await Init(executionContext); //Ensures XrmEx is available by only accessing it after the OnLoad Event | ||
try { | ||
fields.Firstname.Value = "Joe"; | ||
fields.Firstname.setVisible(false).setDisabled(false).setRequired(true); | ||
} catch (error) { | ||
console.error(error); | ||
await XrmEx.openAlertDialog("Error", `Error in ${XrmEx.getMethodName()}\n` + error.message); | ||
} | ||
} | ||
}; | ||
``` | ||
@@ -89,0 +93,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
195171
108