Microsoft Dynamics CRM で使用する AMPscript 関数

Microsoft Dynamics CRM システムとの Salesforce Marketing Cloud 連携でレコードを変更するには、Smart Capture およびランディングページと共にこれらの AMPscript 関数を使用します。

Smart Capture の Null 値を返す 

次の例は、Smart Capture ページで収集された列の値が null の場合に Microsoft Dynamics CRM の AMPscript 関数がその null 値をどのように返すのかを示しています。

1<html>
2<head>
3<title>Test Page for Fetch XML</title>
4</head>
5
6<body>
7%%[
8Set @accountId = CreateMscrmRecord("account", 1, "name", "SC Test")
9Set @contactId = CreateMscrmRecord("contact", 10, "firstname", "Sally", "lastname", "Jo-Bob", "parentcustomerid", CONCAT(@accountId, "|account"), "birthdate", "12/3/1981", "accountrolecode", "3", "creditlimit", "12000.55", "donotemail", "true", "numberofchildren", "4", "exchangerate", "1.115", "address1_longitude", "150.34545")
10]%%
11
12%%[
13Set @contacts = RetrieveMscrmRecordsFetchXML("<fetch mapping='logical' count='50' version='1.0'><entity name='contact' ><attribute name='firstname' /><attribute name='lastname' /><attribute name='jobtitle' /><attribute name='parentcustomerid' /><attribute name='donotemail' /><attribute name='numberofchildren' /><attribute name='birthdate' /><attribute name='exchangerate' /><attribute name='address1_longitude' /><attribute name='accountrolecode' /><attribute name='createdby' /><attribute name='creditlimit' /><attribute name='accountrolecode' /><filter><condition attribute='firstname' operator='eq' value='Sally' /></filter><link-entity name='account' from='accountid' to='parentcustomerid' ><attribute name='name' /></link-entity></entity></fetch>")]%%
14
15            Account Count: %%= RowCount(@accounts) =%%
16            Contact Count: %%= RowCount(@contacts) =%%
17
18<p>Contacts:</p><br><br>
19%%[
20
21for @counter = 1 to rowcount(@contacts) do
22
23set @firstname = field(row(@contacts,@counter),'firstname')
24set @lastname = field(row(@contacts,@counter),'lastname')
25set @name = field(row(@contacts,@counter),'account1.name')
26set @acctRoleCode= field(row(@contacts,@counter),'accountrolecode')
27set @doNotEmail= field(row(@contacts,@counter),'donotemail')
28set @createdBy= field(row(@contacts,@counter),'createdby')
29set @creditLimit= field(row(@contacts,@counter),'creditlimit', 1)
30set @jobTitle= field(row(@contacts,@counter),'jobtitle', 0)
31
32]%%
33
34<p>First: &nbsp; &nbsp; %%=v(@firstname)=%% </p>
35<p>Last: &nbsp; &nbsp; %%=v(@lastname)=%% </p>
36<p>Linked Entity (Account) Name: &nbsp; &nbsp; %%=v(@name)=%% </p>
37<p>Account Role Code: &nbsp; &nbsp; %%=v(@acctRoleCode)=%% </p>
38<p>Do Not Email: &nbsp; &nbsp; %%=v(@doNotEmail)=%% </p>
39<p>Created By: &nbsp; &nbsp; %%=v(@createdBy)=%% </p>
40<p>Credit Limit: &nbsp; &nbsp; %%=v(@creditLimit)=%% </p>
41<p>Job Title: &nbsp; &nbsp; %%=v(@jobTitle)=%% </p> <br><br>
42
43%%[next @counter ]%%
44</body><custom name="opencounter" type="tracking"></html>

検索 

指定された属性を複数の Dynamics CRM エンティティに関連付けることができる場合、次の文字列 (lookup はエンティティに置き換える) を追加して、属性が属するエンティティの種別を指定する必要があります。

1|lookup

たとえば、customerid フィールドを取引先または取引先責任者に関連付けることができるとします。customerid を取引先に関連付ける場合、属性の最後に |account を追加してこれを指定します。

関係者リスト 

一連のフィールドと値の最後に |partyentityname (パイプの後のテキストは独自の名前に置き換える) を含めることで、それらのフィールドと値を使用して関係者リストにレコードを作成できます。このプロセスによって作成されるレコードは 1 つのみですが、別の関係者リストを除く任意の値を入力できます。この属性をキャンペーン応答専用に使用すると、関係者リストがキャンペーン応答の顧客フィールドに直接マップされます。

1"field,value,field2,value2"|examplepartylist

このテキストでは、2 つのフィールド (field と field 2) とそれぞれに割り当てられる値 (value と value2) を使用して examplepartylist にレコードが作成されます。