Skip to content

Commit cb27fe6

Browse files
authored
Live publish
2 parents 72fb423 + 6ca4422 commit cb27fe6

File tree

1 file changed

+66
-7
lines changed

1 file changed

+66
-7
lines changed

powerapps-docs/developer/common-data-service/webapi/use-web-api-actions.md

Lines changed: 66 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: "Use Web API actions (Microsoft Dataverse)| Microsoft Docs"
33
descriptions: "Actions are reusable operations that can be performed using the Web API. These are used with a POST request to modify data on Microsoft Dataverse"
44
ms.custom: ""
5-
ms.date: 10/31/2018
5+
ms.date: 11/21/2020
66
ms.service: powerapps
77
ms.suite: ""
88
ms.tgt_pltfrm: ""
@@ -78,7 +78,15 @@ OData-Version: 4.0
7878

7979
## Bound actions
8080

81-
In the [CSDL metadata document](web-api-types-operations.md#bkmk_csdl), when an `Action` element represents a bound action, it has an `IsBound` attribute with the value `true`. The first `Parameter` element defined within the action represents the entity that the operation is bound to. When the `Type` attribute of the parameter is a collection, the operation is bound to a collection of entities. As an example, the following is the definition of the <xref href="Microsoft.Dynamics.CRM.AddToQueue?text=AddToQueue Action" /> represented in the CSDL:
81+
There are two ways that an action can be bound. The most common way is for the action to be bound by an entity. Less frequently, it can also be bound to an entity collection.
82+
83+
In the [CSDL metadata document](web-api-types-operations.md#bkmk_csdl), when an `Action` element represents a bound action, it has an `IsBound` attribute with the value `true`. The first `Parameter` element defined within the action represents the entity that the operation is bound to. When the `Type` attribute of the parameter is a collection, the operation is bound to a collection of entities.
84+
85+
When invoking a bound function, you must include the full name of the function including the `Microsoft.Dynamics.CRM` namespace. If you do not include the full name, you will get the following error: `Status Code:400 Request message has unresolved parameters`.
86+
87+
### Actions bound to an entity
88+
89+
As an example of an action bound to an entity, the following is the definition of the <xref href="Microsoft.Dynamics.CRM.AddToQueue?text=AddToQueue Action" /> represented in the CSDL:
8290

8391
```xml
8492
<ComplexType Name="AddToQueueResponse">
@@ -93,13 +101,11 @@ In the [CSDL metadata document](web-api-types-operations.md#bkmk_csdl), when an
93101
</Action>
94102
```
95103

96-
This bound action is equivalent to the <xref:Microsoft.Crm.Sdk.Messages.AddToQueueRequest> used by the organization service. In the Web API this action is bound to the <xref href="Microsoft.Dynamics.CRM.queue?text=queue EntityType" />) that represents the <xref:Microsoft.Crm.Sdk.Messages.AddToQueueRequest>.<xref:Microsoft.Crm.Sdk.Messages.AddToQueueRequest.DestinationQueueId> property. This action accepts several additional parameters and returns a <xref href="Microsoft.Dynamics.CRM.AddToQueueResponse?text=AddToQueueResponse ComplexType" /> corresponding to the <xref:Microsoft.Crm.Sdk.Messages.AddToQueueResponse> returned by the organization service. When an action returns a complex type, the definition of the complex type will appear directly above the action in the CSDL.
97-
98-
A bound action must be invoked using a URI to set the first parameter value. You cannot set it as a named parameter value.
104+
This entity bound action is equivalent to the <xref:Microsoft.Crm.Sdk.Messages.AddToQueueRequest> used by the organization service. In the Web API this action is bound to the <xref href="Microsoft.Dynamics.CRM.queue?text=queue EntityType" /> that represents the <xref:Microsoft.Crm.Sdk.Messages.AddToQueueRequest>.<xref:Microsoft.Crm.Sdk.Messages.AddToQueueRequest.DestinationQueueId> property. This action accepts several additional parameters and returns a <xref href="Microsoft.Dynamics.CRM.AddToQueueResponse?text=AddToQueueResponse ComplexType" /> corresponding to the <xref:Microsoft.Crm.Sdk.Messages.AddToQueueResponse> returned by the organization service. When an action returns a complex type, the definition of the complex type will appear directly above the action in the CSDL.
99105

100-
When invoking a bound function, you must include the full name of the function including the `Microsoft.Dynamics.CRM` namespace. If you do not include the full name, you will get the following error: Status Code:400 Request message has unresolved parameters.
106+
An action bound to an entity must be invoked using a URI to set the first parameter value. You cannot set it as a named parameter value.
101107

102-
The following example shows using the <xref href="Microsoft.Dynamics.CRM.AddToQueue?text=AddToQueue Action" /> to add a letter to a queue. Because the type of the `Target` parameter type is not specific (`mscrm.crmbaseentity`), you must explicitly declare type of the object using the `@odata.type` property value of the full name of the entity, including the `Microsoft.Dynamics.CRM` namespace. In this case, `Microsoft.Dynamics.CRM.letter`. More information:[Specify entity parameter type](#bkmk_specifyentityparametertype)
108+
The following example shows using the <xref href="Microsoft.Dynamics.CRM.AddToQueue?text=AddToQueue Action" /> to add a letter to a queue. Because the type of the `Target` parameter type is not specific (`mscrm.crmbaseentity`), you must explicitly declare type of the object using the `@odata.type` property value of the full name of the entity, including the `Microsoft.Dynamics.CRM` namespace. In this case, `Microsoft.Dynamics.CRM.letter`. More information: [Specify entity parameter type](#bkmk_specifyentityparametertype)
103109

104110
**Request**
105111

@@ -132,6 +138,59 @@ OData-Version: 4.0
132138
}
133139
```
134140

141+
### Actions bound to an entity collection
142+
143+
It is less common to find actions bound to an entity collection. The following are some you may find:
144+
145+
|&nbsp; |&nbsp;|&nbsp;|
146+
|-|-|-|
147+
|<xref:Microsoft.Dynamics.CRM.CreateException?text=CreateException Action/>|<xref:Microsoft.Dynamics.CRM.DeliverIncomingEmail?text=DeliverIncomingEmail Action/>|<xref:Microsoft.Dynamics.CRM.ExportTranslation?text=ExportTranslation Action/>|
148+
|<xref:Microsoft.Dynamics.CRM.FulfillSalesOrder?text=FulfillSalesOrder Action/>|<xref:Microsoft.Dynamics.CRM.ValidateSavedQuery?text=ValidateSavedQuery Action >||
149+
150+
As an example of an action bound to an entity collection, the following is the definition of the <xref href="Microsoft.Dynamics.CRM.ExportTranslation?text=ExportTranslation Action" /> represented in the CSDL:
151+
152+
```xml
153+
<ComplexType Name="ExportTranslationResponse">
154+
<Property Name="ExportTranslationFile" Type="Edm.Binary" />
155+
</ComplexType>
156+
<Action Name="ExportTranslation" IsBound="true">
157+
<Parameter Name="entityset" Type="Collection(mscrm.solution)" Nullable="false" />
158+
<Parameter Name="SolutionName" Type="Edm.String" Nullable="false" Unicode="false" />
159+
<ReturnType Type="mscrm.ExportTranslationResponse" Nullable="false" />
160+
</Action>
161+
```
162+
163+
This entity collection bound action is equivalent to the <xref:Microsoft.Crm.Sdk.Messages.ExportTranslationRequest> used by the organization service. In the Web API this action is bound to the <xref href="Microsoft.Dynamics.CRM.solution?text=solution EntityType" />. But rather than passing a value to the request, the entity collection binding simply applies the constraint that the URI of the request must include the path to the specified entity set.
164+
165+
The following example shows using the <xref href="Microsoft.Dynamics.CRM.ExportTranslation?text=ExportTranslation Action" /> which exports a binary file containing data about localizable string values which can be updated to modify or add localizable values. Note how the entity collection bound action is preceded by the entity set name for the solution entity: `solutions`.
166+
167+
**Request**
168+
169+
```http
170+
POST [Organization URI]/api/data/v9.1/solutions/Microsoft.Dynamics.CRM.ExportTranslation HTTP/1.1
171+
Accept: application/json
172+
Content-Type: application/json
173+
OData-MaxVersion: 4.0
174+
OData-Version: 4.0
175+
176+
{
177+
"SolutionName":"MySolution"
178+
}
179+
```
180+
181+
**Response**
182+
183+
```http
184+
HTTP/1.1 200 OK
185+
Content-Type: application/json; odata.metadata=minimal
186+
OData-Version: 4.0
187+
188+
{
189+
"@odata.context": "[Organization URI]/api/data/v9.1/$metadata#Microsoft.Dynamics.CRM.ExportTranslationResponse",
190+
"ExportTranslationFile": "[Binary data Removed for brevity]"
191+
}
192+
```
193+
135194
<a name="bkmk_customActions"></a>
136195

137196
## Use a custom action

0 commit comments

Comments
 (0)