Miss any of our Open RFC calls?Watch the recordings here! »

prince-xrm

1.0.2 • Public • Published

:crown:
prince

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

  1. Import Prince
import Prince from "prince-xrm"
  1. 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(configIPrinceConfig | string)

Store form state so it can be printed later

Prince.storeForm(primaryControlXrm.FormContext | Xrm.Page.EventContext attributestring, config?: IPrinceConfig | string, form?: Form)
  • primaryControl execution context from form or ribbon event.
  • config configuration needed to get @param form.
  • attribute schema name of attribute to store the form in.
  • form form to store. If not given, it is retrieved.

### Print a stored form

Prince.printStoredForm(primaryControlXrm.FormContext | Xrm.Page.EventContext, attributestring)
  • primaryControl execution context from form or ribbon event.
  • attribute schema 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);

After

Backlog

  • Support subgrids shown with view columns
  • Support multiple columns layout on forms
  • Increase customisability through input config IPrinceConfig

Contributing

  1. Clone the prince repository
  2. cd prince`
  3. npm install
  4. Build with npm run build
  5. Lint with npm run lint
  6. Test with jest using npm run test

Install

npm i prince-xrm

DownloadsWeekly Downloads

4

Version

1.0.2

License

ISC

Unpacked Size

732 kB

Total Files

24

Last publish

Collaborators

  • avatar