Generate document (unbound custom API)
- Type: Unbound custom API
- Unique name:
dcpwr_generatedocument - Required privilege: Read access to dcpwr_documenttemplate, dcpwr_documentsetup, and data tables. Write access to the dcpwr_temporaryfile table.
- Available since: 1.0
Use the Generate document action to generate one or more documents from a Document Template merged with Dataverse record data, called directly through the Dataverse Web API. The Docentric CE Tools connector for Power Automate wraps this same action for use in flows.
Action parameters
The action accepts a single JSON-serialized string as its Request parameter. See Request payload schema for the object it represents.
| Name | Type | Description |
|---|---|---|
Request |
string | Required. JSON-serialized string containing the generate document request. See Request payload schema. |
CorrelationId |
string | Optional client-supplied identifier for correlating/tracing the request in telemetry. |
Example HTTP request
POST [organization url]/api/data/v9.2/dcpwr_generatedocument
{
"Request": "{\"recordIds\":[\"6b7cc597-8fde-49fb-8ed7-9a09cdb65924\"],\"templateId\":\"15e52911-ea3c-4238-875f-59820bb054fc\",\"languageTag\":\"en-US\",\"fileName\":\"MyDocument.docx\",\"outputFormat\":\"DOCX\"}"
}
Request payload schema
| Name | Type | Description |
|---|---|---|
recordIds |
array of string (GUID) | Required. Unique identifiers of the Dataverse records to generate the document for. |
templateId |
string (GUID) | Required. Unique identifier of the Document Template to use for generation or template reference code. |
languageTag |
string | Required. Language tag (for example, en-US) used for document content and value formatting. |
fileName |
string | Required. Desired file name for the generated document, including the file extension. |
outputFormat |
string | Required. Desired output format. Allowed values: DOCX, PDF. |
NOTE
Version 1.0 only supports a single record ID per request.
Example request payload
{
"recordIds": [
"6b7cc597-8fde-49fb-8ed7-9a09cdb65924"
],
"templateId": "15e52911-ea3c-4238-875f-59820bb054fc",
"languageTag": "en-US",
"fileName": "MyDocument.docx",
"outputFormat": "DOCX"
}
Response
The action returns a native JSON object of type mscrm.dcpwr_generatedocumentResponse (not a JSON string).
| Name | Type | Description |
|---|---|---|
Response |
string | Required. JSON-serialized string containing the generate document response. See Response payload schema. |
Response payload schema
| Name | Type | Description |
|---|---|---|
documents |
array of object | Required. One entry per generated document. |
documents[].recordIds |
array of string (GUID) | Record IDs associated with this generated document. |
documents[].fileName |
string | Name of the generated document file. |
documents[].temporaryFileUrl |
string (URL) | Download URL for the temporary file content. |
documents[].temporaryFileId |
string (GUID) | Unique identifier of the temporary file record (dcpwr_temporaryfiles). |
documents[].mimeType |
string | MIME type of the generated file. |
documents[].diagnostics |
array of object | Diagnostic information related to the generated document. Each entry contains details about warnings or errors encountered during document generation. |
documents[].diagnostics[].message |
string | Human-readable message describing the diagnostic. |
documents[].diagnostics[].severity |
string | Severity level of the diagnostic (warning or error). |
NOTE
Version 1.0 only supports a single document in response.
Example response payload
{
"documents": [
{
"recordIds": [
"6b7cc597-8fde-49fb-8ed7-9a09cdb65924"
],
"fileName": "MyDocument.docx",
"temporaryFileUrl": "https://dev-eu-crm-demo.crm4.dynamics.com/api/data/v9.0/dcpwr_temporaryfiles(f24d6f3a-ba3f-41d0-b27c-3c8816ac899b)/dcpwr_content/$value",
"temporaryFileId": "f24d6f3a-ba3f-41d0-b27c-3c8816ac899b",
"mimeType": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"diagnostics": [
{
"message": "Sample warning message",
"severity": "warning"
}
]
}
]
}