In this SwiftReports example we are going walk through the steps to create a Certificate template by importing a saved template, and then set up a North52 Dialog to allow the user to run the report from a ribbon button on an Contact record.
Prerequisites:
- A sample Contact record, with an email address specified on the owning user
- A test model-driven app with Contacts page you can add ribbon commands to
- Download the SwiftReports_Sample_Certificate_Template.json file (right-click, Save as…)
Generate Report
- Navigate to SwiftReports
- Click the Start Blank button
- Select Import from File from the SwiftReports menu
- Locate and open the SwiftReports_Sample_Certificate_Template.json file
- The template is loaded.
Update individual elements
Once the report is generated you may need to tweak various aspects to get it how you want.
For example, replace the image with your logo:
- Click the image element
- Copy your png/jpg logo image to your clipboard
- Paste into the Image Source field - you will see a preview of the image shown in the designer
Preview your template at anytime
- Use Preview with sample data option from the PDF menu in the top right (the Preview with a real record option can be used once the report has been saved)
Save the report
- Select Save from the SwiftReports menu
- Select the Solution you would like to save the template to
- In the Display Name field type Certificate Template
- Click Save
Test Generation
Now that the report has been saved we can do a live Test Generation against a selected record.
- Select the Preview with a real record option from the PDF menu in the top right
- Click the ... button beside the Record ID field
- Select Contact in the Look for: field
- Click the Results button in the top left to list the contact records
- Select the record for your test
- Click the Add button (or double-click the selected record above)
- Click Generate PDF
- The Generated PDF opens in a new tab
Create North52 Dialog
To make it easy for users to generate a PDF from your template you can easily deploy a North52 Dialog. Dialogs open from the ribbon menu and provide one-click options to generate reports.
- From the SwiftReports menu select Dialogs
- Click Quick Create
- Select the Contact table
- Check the Add option for the Certificate Template
- Click on Create 1 button
- Enter a Title for your Dialog e.g. Create Certificate
- From the Preview menu in the top right, select Preview - this opens a dialog with showing the button with defaulted labels and colours. The preview is purely to assess how it looks, the button does not work.
Save the Button
- Select Save from the North52 Dialogs menu
- Select the Solution you would like to save the dialog to
- Leave the default text in the Display Name field unless you want to change it
- Click Save
Test with a Record
Before you deploy your dialog to be accessed from a Ribbon button, you can test using a record.
- From the Preview menu in the top right, select Test with a Record
- Click the ellipses (…) button beside the Record ID field to open the Watson record explorer
- In the Look for menu select the Contacts table
- Click the Results button to list all the Contact records
- Click to select the record for your test, then click the Select Record button (alternatively, double-click the row to select the record and close the dialog)
- Click Run
- The Dialog opens in the context of your selected record
- Click on the dialog button
- The Certificate PDF if generated and displayed within the Dialog
- Click Download to save the PDF to your computer
Deploy
Deploying the Dialog creates a command button that displays in the Dataverse navigation ribbon
- Expand the Command Bar Deployments section
- Click the Deploy Button
- Select the Model-driven app you would like the command button to display in (we suggest creating a separate test app)
- The Table is preselected, and should not be changed for this example
- Leave Form selected for the Location
- The Button label is defaulted, change it if you would like something different
- For Icon, select Web Resource, the search for swift and select the North52IconSwiftReports.svg web resource
- Select the Solution you would like the customization to be saved to
- Select an appropriate Position for the button, e.g. Save, so that the button appears after the Save button
- Click Create Button - the deployment begins, saving the command button, publishing changes and saving the dialog
Test
The ribbon is aggressively cached, so the quickest way to see the change is to open a Private/Incognito browser session and navigate to an Contact record. Alternatively, from the browser development tools, choose Application > Storage, and Clear site data (make sure you uncheck Cookies first, otherwise you will be logged out)
- Click the Create Certificate ribbon button, and then click the Create Certificate dialog button
- The Certificate PDF if generated and displayed within the Dialog
- Click Download to save the PDF to your computer
Clean up
To remove the North52 Dialog and any related command buttons, you can delete the Dialog web resource:
- Select Open from the Dialogs menu
- Select the Solution that contains the Dialog web resource
- Click the trash can icon to delete the web resource
- If the Dialog is referenced by any command button a warning dialog will show with options to remove the command buttons
