prince-xrm
v1.0.2
Published
Prints your Dynamics 365 forms.
Readme
Prints Dynamics 365 forms as pdf's.
Converts forms to .pdf report using jsPDF, including form's:
- visible attributes that contain data
- subgrids (rendered as nested forms)
- embedded web resources that display text
Installing
For the latest stable version, copy from /dist/prince.min.js or
npm i prince-xrm.
Usage
- Import Prince
import Prince from "prince-xrm"- Create a config object extending
IPrinceConfig
export default interface IPrinceConfig {
entityName: string;
entityId: string;
forms?: Array<{
formId: string;
entityName: string;
}>;
webResources?: Array<{
name: string;
attribute: string;
}>;
}Print form
Prince.printForm(config: IPrinceConfig | string)Store form state so it can be printed later
Prince.storeForm(primaryControl: Xrm.FormContext | Xrm.Page.EventContext attribute: string, config?: IPrinceConfig | string, form?: Form)primaryControlexecution context from form or ribbon event.configconfiguration needed to get @param form.attributeschema name of attribute to store the form in.formform to store. If not given, it is retrieved.
Print a stored form
Prince.printStoredForm(primaryControl: Xrm.FormContext | Xrm.Page.EventContext, attribute: string)primaryControlexecution context from form or ribbon event.attributeschema name of the attribute where the form string is stored.
Examples
Creating a config
const config = {
entityId: "BB42C9F1-AE20-E911-A974-0022480186C3",
entityName: "new_parent",
forms: [
{
entityName: "new_parent",
formId: "592e38a0-d028-493f-b916-d89a87a6d1b2",
},
{
entityName: "new_child",
formId: "37A83C9B-76D1-46A0-976C-9AA6168AA279",
},
],
webResources: [
{
attribute: "new_simpletext",
name: "WebResource_SimpleText",
},
],
};Storing a form and printing it
import Prince from "prince-xrm";
Prince.storeForm(executionContext, "new_formstorage");
Prince.printStoredForm(executionContext, "new_formstorage");There's no need to store a form and immediately print it, as this can be done in one line using
Prince.printForm. However you may want to store and print a form in separate functions, so that the state of a form can be stored at one moment in time and printed at a later date.
Printing a form
import Prince from "prince-xrm";
Prince.printForm(config);
Backlog
- Support subgrids shown with view columns
- Support multiple columns layout on forms
- Increase customisability through input config
IPrinceConfig
Contributing
- Clone the prince repository
- cd prince`
npm install- Build with
npm run build - Lint with
npm run lint - Test with jest using
npm run test
