This activity allows you to query Dynamics 365 for a data set and get the results back in a number of formats. You’ll always get the results formatted as an HTML table to insert in an email or a CSV suitable for descriptions of tasks or other non-html fields.
You will also get back a text parameter containing a list of the first column of results (say, you want to get a list of order IDs for a customer).
Finally, if you’re looking for a scalar query and you’re concerned about the first row, first column, there are type-specific return parameters for that value. This is perfect for Fetch queries where you’re running aggregation queries on the data and want to do a Check condition with the result.
The query can either bring back all records that match a query, or you can limit it to records related to whatever the workflow is running on (check out ‘How to: Limit query result to related records’ for more details).
Usage Examples:
- When a customer pays an invoice, get a table of their products to include in a receipt.
- When a customer opens a case, if they have spent more than $10,000 in the last 6 months, route it to a VIP queue.
Input Parameters
Parameter Name | Type | Description | Default |
Pick a System View to Use | Saved Query record | A CRM view which was created as a system view. These are typically included with CRM out of the box or in other solutions. | {null} |
or pick a Personal View to Use | User Query record | A CRM view which was created as a personal view. | {null} |
or enter FetchXML to Use | Text | A CRM query represented by FetchXML. If you copy and paste it from CRM, make sure to remove all the line breaks before you paste it in or CRM may cut off the text and the query won’t be valie. | {null} |
Include Header for Table? | Boolean | Indicates if the Header row should be rendered. Header column names are based off the query results. | True |
Table – Border Color | Text | The color of the grid lines. | #000000 (Black) |
Header – Background Color | Text | The background color for the header. | #6495ED (Cornflower Blue) |
Header – Font Color | Text | The font color of text in the header. | #FFFFFF (White) |
Header – Make Font Bold | Boolean | Indicated if the header text should be bolded | True |
Row – Background Color | Text | The background color of data rows 1, 3, 5… | #FFFFFF (White) |
Row – Font Color | Text | The font color of data rows 1, 3, 5… | #000000 (Black) |
Alternating Row – Background Color | Text | The background color of data rows 2, 4, 6… | #F0F8FF (Alice Blue) |
Alternating Row – Font Color | Text | The font color of data rows 2, 4, 6… | #000000 (Black) |
List – Item separator | Text | The separator to use building the list | Comma and a space: ‘. ‘ |
List – Include Empty Items | Boolean | If a list should include empty items | False |
Output Parameters
Parameter Name | Type | Description |
# of Results | Whole Number | The number of rows returned when the query is executed. |
Table – Query Results (HTML) | Text | The table results, formatted as HTML based on the default styles. This can be used for emails or other HTML enabled fields. |
Table – Query Results (CSV) | Text | The table results with no special formatting. The cells are separated with a comma (,) and rows with a line break. This should be used when for non-HTML fields like Description on an activity or more other text fields. |
List – Query Results as a List | Text | The first column of results, separated with a comma or other specified separator. |
Single Value – Result as Whole Number | Whole Number | First row, first column of the result set, if the value can be parsed as a whole number |
Single Value – Result as DateTime | Date Time | First row, first column of the result set, if the value is a date time. |
Single Value – Result as Decimal | Decimal | First row, first column of the result set, if the value can be parsed as a decimal. |
Single Value – Result as Double | Double | First row, first column of the result set, if the value can be parsed as a double. |
Single Value – Result as Money | Money | First row, first column of the result set, if the value can be parsed as a decimal (then cast as a Money). |
Single Value – Result as ID | Text | First row, first column of the result set, if the value can be parsed as a Guid. This is the text value of the ID since Guid is not a valid return type. |
Single Value – Result as Text | Text | The text value of the first row, first column of the result set. |