Dataverse allows you to easily generate your Word Templates as PDF files. Last year they expanded the functionality beyone just the out of the box sales entities to all custom entities. In order to enable the functionality though you need to do some configuration. Below are the different methods in which you can turn the PDF generation on or off for entities.
Note: Aftert updating these settings in whatever manor make sure you clear your browser data. The ribbon stores the values for which entities are enabled and disabled within the browser session. If you don’t do this you may not see the PDF generation buttons show up after you enable them.
For those orgs that have the Sales Hub app this is fairly straightforward.
https://<Your Org>.crm.dynamics.com/apps
If you have the Sales solution installed you can access the the Convert to PDF page using the following url which you could put in the sitemap.
https://<Your Org>.crm.dynamics.com/main.aspx?pagetype=control&controlName=MscrmControls.FieldControls.CCFadminsettings&data={"id":"overview","ismanage":"overview"}
If you don’t have sales installed on your system you can still enable this feature but it takes a bit more work. The easiest way is to utilize some of the tools in XrmToolBox.
First we will open FetchXML Builder and retrieve the pdfsetting entity, we will need to specify the pdfsettingsid and pdfsettingsjson attributes. This will return a single records. Copy the outputs of these fields to your text editor.
Next I will utilize the WebAPI Launcher to update the pdfsettign entity with our updated json which will contain all the entities you want to enable for PDF generation.
Because the PDF settings are stored per envrionment you may want to update them as part of your ALM. One way of doing this would be to run a PowerShell script which sets them during deployment. To learn more about how to connect to Dataverse using PowerShell check out this article. The following Invoke-RestMethod calls would get the existing pdfsetting entity and then update that entity with the JSON you want.
##########################################################
# GET THE PDF SETTINGS ENTITY
##########################################################
$pdfSettingRetrieveUriParams="$select=pdfsettingid,pdfsettingsjson&$top=1"
$pdfSettingRetrieveParams =
@{
URI = "$($dataverseEnvUrl)/api/data/v9.1/pdfsettings?$($pdfSettingRetrieveUriParams)"
Headers = @{
"Authorization" = "$($authResponse.token_type) $($authResponse.access_token)"
}
Method = 'GET'
}
# Get the pdf settigns entity
$pdfSettignsRetriveRequest = Invoke-RestMethod @pdfSettingRetrieveParams -ErrorAction Stop
$pdfSettignsRetriveResponse = $pdfSettignsRetriveRequest
#Output the results
$pdfSettingsValue = $apiCallResponse.value
##########################################################
# UPDATE THE PDF SETTINGS ENTITY
##########################################################
$pdfSettingJSON = '{ "pdfsettingsjson" : ''{"contact": true, "account": true}'' }'
$pdfSettingUpdateParams =
@{
URI = "$($dataverseEnvUrl)/api/data/v9.1/pdfsettings($($pdfSettingsValue.pdfsettingid))"
Headers = @{
"Authorization" = "$($authResponse.token_type) $($authResponse.access_token)"
}
Method = 'PATCH'
Body = $pdfSettingJSON
ContentType = "application/json"
}
# Update the pdf settings entity
$pdfSettignsUpdateRequest = Invoke-RestMethod @pdfSettingUpdateParams -ErrorAction Stop
$pdfSettignsUpdateResponse = $pdfSettignsUpdateRequest
Original Post http://www.richardawilson.com/2021/06/enable-export-to-pdf-button-ribbon.html