All docs This doc
||
Skip to end of metadata
Go to start of metadata


Overview

The following operations allow you to work with update entities. Click operation to see details on how to use it.

OperationsDescription
updateEntityUpdate an entity using the Web API.
updateEntityWithDataReturnedOrSinglePropertyValueTo get the data when updating the entity or updating the value of a single property of an entity.
upsertEntityTo Upsert an Entity.

For a sample proxy service that illustrates how to work with update entities, see Sample configuration.

Operation details

Following is more information about each of the operations.

Update an Entity

To update an entity, use msdynamics365.updateEntity.

updateEntity
<msdynamics365.updateEntity>
    <entityType>{$ctx:entityType}</entityType>
    <bodyContent>{$ctx:bodyContent}</bodyContent>
    <primaryKeyValue>{$ctx:primaryKeyValue}</primaryKeyValue>
</msdynamics365.updateEntity>
Properties
  • entityType: Required - The type of an entity (i.e accounts, opportunities, contacts and etc).
  • bodyContent:Required - The required content to update an entity.

  • primaryKeyValue: Required - The primary key value of an entity.
Sample request

Following is a sample REST/JSON request that can be handled by the updateEntity operation.

Sample Request for Update Entity
{
       
       	"apiUrl":"https://wso2.crm5.dynamics.com",
       	"accessToken":"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IjlGWERwYmZNRlQyU3",
       	"refreshToken":"AQABAAAAAABnfiG-mA6NTae7CdWW7Qfd0aAk9Jh2jERSJt61ivkdC_8VpI4B75AWvtviJErRhnzKIDvt",
       	"clientSecret":"iDJ7gQ81N+JAW9Ql2/ikMzc9og",
       	"clientId":"c12ec5be-8356-ed0915a",
       	"resource":"https://wso21234.crm5.dynamics.com/",
       	"registryPath":"",
       	"intervalTime":"",
       	"entityType":"accounts",
		"bodyContent":{"name": "Updated Sample Account ","creditonhold": true,"address1_latitude": 37.639583,"description": "Test", "revenue": 6000000}
		"primaryKeyValue":"00000000-0000-0000-0000-000000000001"
}

For more information on Update Entities, see https://msdn.microsoft.com/en-us/library/mt607664.aspx#bkmk_update.

Update Entity With Data Returned Or Update Single Property Value

To update entity with data returned or update single property value, use msdynamics365.updateEntityWithDataReturnedOrSinglePropertyValue.

updateEntityWithDataReturnedOrSinglePropertyValue
<msdynamics365.updateEntityWithDataReturnedOrSinglePropertyValue>
    <entityType>{$ctx:entityType}</entityType>
    <bodyContent>{$ctx:bodyContent}</bodyContent>
    <primaryKeyValue>{$ctx:primaryKeyValue}</primaryKeyValue>
    <queryParam>{$ctx:queryParam}</queryParam>
    <singlePropertyName>{$ctx:singlePropertyName}</singlePropertyName>
</msdynamics365.updateEntityWithDataReturnedOrSinglePropertyValue>
Properties
  • entityType: Required - The type of an entity (i.e accounts, opportunities, contacts and etc).
  • bodyContent:Required - The required content to update an entity with data returned or update single property value of an entity.

  • primaryKeyValue: Required - The primary key value of an entity.
  • queryParam: Required - If you want to return the data in response when an entity updated, then set the properties as query.

  • singlePropertyName: Required - If you want to update a single property name, then set this property with the relevant value. (Name of the single property to update its value).

Sample request

Following is a sample REST/JSON request that can be handled by the Update Entity With Data Returned.

Sample Request for Update Entity With Data Returned
{
       
       	"apiUrl":"https://wso2.crm5.dynamics.com",
       	"accessToken":"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IjlGWERwYmZNRlQyU3",
       	"refreshToken":"AQABAAAAAABnfiG-mA6NTae7CdWW7Qfd0aAk9Jh2jERSJt61ivkdC_8VpI4B75AWvtviJErRhnzKIDvt",
       	"clientSecret":"iDJ7gQ81N+JAW9Ql2/ikMzc9og",
       	"clientId":"c12ec5be-8356-ed0915a",
       	"resource":"https://wso21234.crm5.dynamics.com/",
       	"registryPath":"",
       	"intervalTime":"",
       	"entityType":"accounts",
       	"primaryKeyValue":"00000000-0000-0000-0000-000000000001",
		"bodyContent":{"name":"Updated Sample Account"},
		"queryParam":"name,creditonhold,address1_latitude,description,revenue"
 }

Following is a sample REST/JSON request that can be handled by the Update Single Property Value.

Sample Request for Update Single Property Value
{
       
       	"apiUrl":"https://wso2.crm5.dynamics.com",
       	"accessToken":"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IjlGWERwYmZNRlQyU3",
       	"refreshToken":"AQABAAAAAABnfiG-mA6NTae7CdWW7Qfd0aAk9Jh2jERSJt61ivkdC_8VpI4B75AWvtviJErRhnzKIDvt",
       	"clientSecret":"iDJ7gQ81N+JAW9Ql2/ikMzc9og",
       	"clientId":"c12ec5be-8356-ed0915a",
       	"resource":"https://wso21234.crm5.dynamics.com/",
       	"registryPath":"",
       	"intervalTime":"",
       	"entityType":"accounts",
       	"primaryKeyValue":"00000000-0000-0000-0000-000000000001",
		"singlePropertyName":"name"
 }

Upsert Entity

To upsert entity with data returned, use msdynamics365.upsertEntity.

With the upsert operation ,  if the entity doesn’t exist it will be created. If it already exists, it will be updated.

upsertEntity
<msdynamics365.upsertEntity>
    <entityType>{$ctx:entityType}</entityType>
    <bodyContent>{$ctx:bodyContent}</bodyContent>
    <primaryKeyValue>{$ctx:primaryKeyValue}</primaryKeyValue>
    <preventCreateInUpsert>{$ctx:preventCreateInUpsert}</preventCreateInUpsert>
</msdynamics365.upsertEntity>
Properties
  • entityType: Required - The type of an entity (i.e accounts, opportunities, contacts and etc).
  • bodyContent:Required - The required content to perform the upsert operations.

  • primaryKeyValue: Required - The primary key value of an entity.
  • preventCreateInUpsert:  Possible value of this property is true or false. If the value is true then you can perform Prevent create in upsert operations, otherwise you can perform Prevent update in upsert operations.

Info

Prevent create in upsert : If you are updating data and there is some possibility that the entity was deleted intentionally, you will not want to re-create the entity.

Prevent update in upsert: If you’re inserting data, there is some possibility that a record with the same id value already exists in the system and you may not want to update it.

Sample request

Following is a sample REST/JSON request that can be handled by the upsertEntity operations.

Sample Request for Upsert Entity
{    
       	"apiUrl":"https://wso2.crm5.dynamics.com",
       	"accessToken":"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IjlGWERwYmZNRlQyU3",
       	"refreshToken":"AQABAAAAAABnfiG-mA6NTae7CdWW7Qfd0aAk9Jh2jERSJt61ivkdC_8VpI4B75AWvtviJErRhnzKIDvt",
       	"clientSecret":"iDJ7gQ81N+JAW9Ql2/ikMzc9og",
       	"clientId":"c12ec5be-8356-ed0915a",
       	"resource":"https://wso21234.crm5.dynamics.com/",
       	"registryPath":"",
       	"intervalTime":"",
       	"entityType":"accounts",
		"bodyContent":{"name": "Updated Sample Account ","creditonhold": true},
 		"primaryKeyValue":"00000000-0000-0000-0000-000000000001",
		"preventCreateInUpsert":"false"
 }

For more information on Upsert Entity, see https://msdn.microsoft.com/en-us/library/mt607664.aspx#bkmk_upsert.

Sample configuration

Following is a sample proxy service that illustrates how to connect to Microsoft Dynamics 365 with the init operation and use the updateEntity operationTo view the sample request for this proxy, see Sample Request for the updateEntity operation. You can use this sample as a template for using other operations in this category.

Sample Proxy
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="msdynamics_updateEntity"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
    <target>
        <inSequence>
           	<property expression="json-eval($.apiUrl)" name="apiUrl"/>
			<property expression="json-eval($.accessToken)" name="accessToken"/>
			<property expression="json-eval($.entityType)" name="entityType"/>
			<property expression="json-eval($.bodyContent)" name="bodyContent"/>
			<property expression="json-eval($.primaryKeyValue)" name="primaryKeyValue"/>
 			<property expression="json-eval($.apiVersion)" name="apiVersion"/>
			<property expression="json-eval($.refreshToken)" name="refreshToken"/>
			<property expression="json-eval($.clientSecret)" name="clientSecret"/>
			<property expression="json-eval($.clientId)" name="clientId"/>
			<property expression="json-eval($.resource)" name="resource"/>
			<property expression="json-eval($.registryPath)" name="registryPath"/>
			<property expression="json-eval($.intervalTime)" name="intervalTime"/>
           	<msdynamics365.init>
    			<apiUrl>{$ctx:apiUrl}</apiUrl>
    			<accessToken>{$ctx:accessToken}</accessToken>
    			<apiVersion>{$ctx:apiVersion}</apiVersion>
    			<refreshToken>{$ctx:refreshToken}</refreshToken>
    			<clientSecret>{$ctx:clientSecret}</clientSecret>
    			<clientId>{$ctx:clientId}</clientId>
    			<resource>{$ctx:resource}</resource>
    			<registryPath>{$ctx:registryPath}</registryPath>
    			<intervalTime>{$ctx:intervalTime}</intervalTime>
			</msdynamics365.init>
            <msdynamics365.updateEntity>
    			<entityType>{$ctx:entityType}</entityType>
    			<bodyContent>{$ctx:bodyContent}</bodyContent>
    			<primaryKeyValue>{$ctx:primaryKeyValue}</primaryKeyValue>
			</msdynamics365.updateEntity>
            <respond/>
        </inSequence>
        <outSequence>
            <send/>
        </outSequence>
    </target>
    <description/>
</proxy>                          


  • No labels