Dynamics 365 for Sales Execute

In this article

Overview

This Snap calls the Microsoft Dynamics 365 for Sales REST WebAPI endpoint using the incoming data and writes out a JSON response.

Settings for Dynamics 365 for Sales Execute Snap

ETL Transformations & Data Flow

This Snap enables the following ETL operations or flows:

  • Extract data from the upstream Snap containing the data for performing the provided action on the Microsoft Dynamics 365 For Sales object(s).

  • Transform the input document into a SnapLogic-friendly JSON Document.

  • Load the data into the Dynamics 365 For Sales Execute Snap to perform the operation on the Microsoft Dynamics 365 For Sales object(s).

Snap Type

Dynamics 365 for Sales Execute is a Write-type Snap that executes requests to MS Dynamics 365.

Prerequisites

You must have a Dynamics 365 OAuth2 Account for Online, data to query, and access to the objects concerned.

Support

Works in Ultra Task Pipelines.

Limitations

The following limitations are due to the API limitations from the Microsoft Dynamics 365 for Sales application:

  • The Snap fails with an error when the number of requests exceeds 6000 within 300 seconds. We recommend that you limit the number of requests you make within 300 seconds (5 minutes). You can gradually increase the requests that reduce the retry-after duration, optimize your throughput, and minimize resource spikes on the server.

  • The Snap fails with an error when the combined execution time of incoming requests exceeds the limit of 1,200,000 milliseconds within the window of 300 seconds. We recommend that you reduce the number of concurrent requests or reduce the duration of requests and try later.

  • The Snap fails with an error when the number of concurrent requests exceeds the limit of 52. We recommend that you reduce the number of concurrent requests.

Known Issues

The Execute Snap currently does not fetch schema. Currently, the user is expected to craft the upstream request body completely.

Snap Views

Type

View

Number of Views

Examples of Upstream and Downstream Snaps

Description

Type

View

Number of Views

Examples of Upstream and Downstream Snaps

Description

Input

Document

Min: 0
Max: 1

Any Snap, such as a Mapper or JSON Generator Snap, that offers a document as output. 

The mandatory fields required for executing the concerned operation on the Microsoft Dynamics 365 For Sales object(s).

Output

Document

Min: 1
Max: 1

None

A document with the result set. If the operation is successful, then the output document will contain the information on the Microsoft Dynamics 365 For Sales object(s) being operated.

Error

Error handling is a generic way to handle errors without losing data or failing the Snap execution. You can handle the errors that the Snap might encounter while running the Pipeline by choosing one of the following options from the When errors occur list under the Views tab. The available options are:

  • Stop Pipeline Execution: Stops the current pipeline execution when the Snap encounters an error.

  • Discard Error Data and Continue: Ignores the error, discards that record, and continues with the rest of the records.

  • Route Error Data to Error View: Routes the error data to an error view without stopping the Snap execution.

Learn more about Error handling in Pipelines.

Snap Settings

  • Asterisk (*): Indicates a mandatory field.

  • Suggestion icon (): Indicates a list that is dynamically populated based on the configuration.

  • Expression icon (): Indicates whether the value is an expression (if enabled) or a static value (if disabled). Learn more about Using Expressions in SnapLogic.

  • Add icon (): Indicates that you can add fields in the field set.

  • Remove icon (): Indicates that you can remove fields from the field set.

Field Name

Field Type

Description

Field Name

Field Type

Description

Label*

 

Default ValueDynamics 365 for Sales Execute
ExampleDynamics 365 for Sales Execute

String

Specify the name for the Snap. You can modify this to be more specific, especially if you have more than one of the same Snap in your Pipeline.

Dynamics Organization URL*



Default Value: https://<organization>/api/data/<version>/<api>

Example:
https://abcxyzcompany.api.crm.dynamics.com/api/data/v8.2/

(Example of a GET request for a specific account)
https://abcxyzcompany.api.crm.dynamics.com/api/data/v8.2/accounts(GUID)  

String/Expression

Specify the URL for the Microsoft Dynamics 365 For Sales WebAPI endpoint.  Although the URL is editable, query parameters should not be placed within the URL, as that will not work with the supporting libraries. The Query Parameter fields must be explicitly-used query parameter values, such as search filters, etc.

This field is suggestible, and shows the user's currently configured Account URL. The REST resource, etc. can be then crafted onto the resulting URL.

Object Type

 

Default Value: account

String/Expression

Specify the Microsoft Dynamics 365 for Sales object type to allow its schema to be fetched by the Snap. Custom object types are currently not supported.

 

HTTP Method*

Default Value: GET
Example: POST

Dropdown list

Specify the HTTP REST Method to be used in the request. Available options are:

  • GET

  • POST

  • PUT

  • PATCH

  • DELETE



HTTP Request Body

 

Default Value: $
Example: "{\"name\" : \"Microsoft\"}"

String/Expression

Specify the request body directly in this field for write actions, such as POST or PATCH; however, this field is not required for actions such as GET or DELETE.  If you do not specify the request body directly, then it must be in the form of a JSON String.  Note that the double quotes in the String need to be "Java escaped".

Typically the request body will be provided by an upstream Snap such as a Mapper Snap or JSON Generator Snap.  Therefore, the field defaults to being expression enabled, and the expression is set to "$" which represents the JSON body provided by the upstream Snap.

Query Parameters





Use the Query Parameters fieldset to define search query parameters and their values. The query parameters will be attached to the URL using the HTTP query parameter syntax, separated by '&' and added as key=value.

Parameter

 

Default Value: N/A
Example: $filter

String

Specify the attribute that would be used as a key in your query.

Example: $filter: A value of $filter is typically used as part of a GET request. For example, the user may want to GET Account objects where a given filter condition exists.  Microsoft Dynamics 365 provides a number of special functions that accept parameters, return Boolean values, and can be used as filter criteria in a query. For a list of these functions, see Microsoft Web API Query Function Reference

The following is an example of the Between Function searching for accounts with a number of employees between 5 and 2000:

Value

 

Default Value: N/A
Example: "name eg'" + $name + "'%

String/Expression

Specify the value associated with the parameter chosen in the Parameter field in the Query Parameters fieldset.

For example, if the Parameter was $filter, the value could be ['"name eq 'Microsoft' or 'revenue gt 100' or "address1_fax eq '1234567'".]

When specifying a value that is a string (name or address1_fax), the value must be encased in single quotes. If the value is truly a number, as in the example: 'revenue gt 100', the value must not be encased in single quotes.

Microsoft has provided the following documentation on the Filtering Sunctionality.

Number of Retries


Default Value: 0
Example: 1

Integer

Specify the maximum number of attempts to be made to receive a response. The request is terminated if the attempts do not result in a response.

Retry Interval (seconds)


Default Value: 1
Example: 5

Integer

Specify the time interval between two successive retry requests. A retry happens only when the previous attempt resulted in an exception. 

When the Snap encounters 429 error, the response includes the retry-after with <number of seconds> in the header and the Snap automatically retries after the specified <number of seconds>.



HTTP Header

Use this fieldset to add additional HTTP headers to pass when sending requests to the Dynamics 365 for Sales instance.

Key

 

Default Value: N/A
Example: Prefer

String/Expression

Specify the HTTP header key.

Value

 

Default Value: N/A
Example:  odata.include-annotations="*"

String/Expression

Specify the HTTP header value.

Enable continue on error

 

Default Value: Deselected

Checkbox

Select this checkbox to enable the service to continue processing the remaining requests in a batch when an error occurs. The code continues to execute until all requests are processed. It then returns the response to the output view.

When this checkbox is deselected, the batch process errors out immediately on the first failed request. It then returns a response in the error view that includes the error message.

Snap Execution


Default Value: Execute only
Exdample: Validate & Execute

Dropdown list

 

Troubleshooting

To check whether an operation has been completed as expected, perform the same operation directly on the user interface or by sending the appropriate JSON request to the MS Dynamics 365 For Sales WebAPI endpoint. Use Postman (version 6.0.10 minimum) and collect the necessary data. To see if there are any inconsistencies, compare the data used in the user interface or Soap UI with the SnapLogic pipelines.

Error

Reason

Resolution

Error

Reason

Resolution

-2147015903

The execution time of all the incoming requests exceeded the limit of 1,200,000 milliseconds within the window of 300 seconds.

Reduce the number of concurrent requests or reduce the duration of requests (20 minutes (1200 seconds) within the window of 5 minutes) and try later.

-2147015902

The number of requests exceeded the limit of 6000 within 300 seconds.

Limit the number of requests to 6000 you make within the window of 300 seconds (5 minutes).

-2147015898

The number of concurrent requests exceeded the limit of 52.

Limit the number of concurrent requests.

Too many Requests - 429

There are too many requests sent to Dynamics 365 For Sales endpoint.

The Microsoft Dynamics 365 For Sales related Snaps, include retry-after with <number of seconds> in the response header and automatically retries when they encounter status 429 error. Therefore, wait for the retry to succeed.

Examples


Using Dynamics 365 for Sales Execute as a Standalone Snap

Basic use case: Retrieving an organization's account information

This pipeline demonstrates how the Execute Snap functions as a standalone Snap in a pipeline. 

In this example, we shall retrieve all the Accounts present in the Microsoft Dynamics 365 For Sales Org:

The Execute Snap's configuration is the following:

Download the sample pipeline

Using Upstream Snaps with the Execute Snap


Basic Use Case: Creating an account using the Execute Snap

The following pipeline demonstrates how you can use the Execute Snap to create an Account.

In this example, we have used a JSON Generator Snap to capture the details we want to use to create an account. This is the JSON document provided by the generator:

We now add an Execute Snap downstream to the JSON Generator.

Two configurations to be made here:

  • Once you have entered–or selected the Dynamics Organization URL from the drop-down list, you need to append the word 'accounts' to the URL, as shown in the screenshot above.

  • Select the HTTP Method as POST.

Save and close the Snap Settings popup and execute the pipeline.

For a successful execution, you should see JSON output similar to the one shown below:

Download the sample pipeline

Advanced Use Case: Querying an account using query parameters within the Execute Snap

The following pipeline demonstrates how you can implement a filter the Execute Snap's query parameters to retrieve a specific Account.

In this example, we have used a Mapper Snap to pass the value we are searching for into the name variable.

Now we craft the query parameter key and value pair in the Execute Snap. Note:  In order to follow Microsoft Dynamics 365 For Sales guidelines, we have to surround our "$name" variable with single quotes. This is because the "$name" variable is going to be evaluated by Microsoft as a string of characters. If we had been evaluating a numeric value such as a dollar amount, we would not surround the variable in single quotes. Note that there are some values that are entirely full of numeric characters, but are in fact strings (phone numbers, fax numbers, etc). Microsoft has provided the following detailed information regarding the use of "$filter" queries: Query Data using the Web API.

Now we see that we were able to execute the request successfully and have indeed retrieved the account with the specified "$name" variable:

Download the sample pipeline

Downloads

Snap Pack History