1. 相互作用の作業

インタラクションを得て

Version:
日本語翻訳に関する免責事項

このページの翻訳はAIによって自動的に行われました。可能な限り正確な翻訳を心掛けていますが、原文と異なる表現や解釈が含まれる場合があります。正確で公式な情報については、必ず英語の原文をご参照ください。

.GetAsync() / .Get() を使って相互作用または相互作用の集合を取得します。相互作用は以下で取得できます:

  • インタラクションIDとコンタクトIDの組み合わせ
  • インタラクションIDとコンタクト参照の組み合わせ

!注コンタクトIDまたはコンタクトリファレンスは、シャード環境でのクエリ効率を高めるために含まれています。コレクションデータはコンタクトID上でシャード化されるため、クエリにコンタクトIDを含めることで、xConnectはどのシャードがインタラクションデータを保持しているかを即座に把握できます。

次の例では、2つの相互作用が引き出されます。

using Sitecore.XConnect; using System; using System.Collections.Generic; using System.Threading.Tasks; using System.Collections.ObjectModel; using Sitecore.XConnect.Operations; using Sitecore.XConnect.Client;

namespace Documentation { public class GetInteractions { // Async interaction public async void ExampleAsync() { using (Sitecore.XConnect.Client.XConnectClient client = Sitecore.XConnect.Client.Configuration.SitecoreXConnectClientConfiguration.GetClient()) { try {

var interactionIdOne = Guid.Parse("DA2DA5F0-4348-E611-82E7-34E6D7117DCB"); var interactionIdTwo = Guid.Parse("B9814105-1F45-E611-82E6-34E6D7117DCB");

// Contact reference from ID var contactRef = new ContactReference(interactionIdOne); Sitecore.XConnect.InteractionReference interactionRef = new Sitecore.XConnect.InteractionReference(contactRef, interactionIdTwo);

// Contact reference from identifier var identifiedContactRef = new IdentifiedContactReference("twitter", "myrtlesitecore"); Sitecore.XConnect.InteractionReference secondInteractionRef = new Sitecore.XConnect.InteractionReference(identifiedContactRef, Guid.Parse("E6067926-1F45-E611-82E6-34E6D7117DCB"));

var references = new List<Sitecore.XConnect.InteractionReference>() { interactionRef, secondInteractionRef };

Task<ReadOnlyCollection<IEntityLookupResult>> interactionTask = client.GetAsync<Sitecore.XConnect.Interaction>(references, new InteractionExecutionOptions(new InteractionExpandOptions() { }));

ReadOnlyCollection<IEntityLookupResult> interaction = await interactionTask; } catch (Exception ex) { // Manage exceptions } } }

// Sync example public async void ExampleSync() { using (Sitecore.XConnect.Client.XConnectClient client = Sitecore.XConnect.Client.Configuration.SitecoreXConnectClientConfiguration.GetClient()) { try {

var interactionIdOne = Guid.Parse("DA2DA5F0-4348-E611-82E7-34E6D7117DCB"); var interactionIdTwo = Guid.Parse({B9814105-1F45-E611-82E6-34E6D7117DCB});

// Contact reference from ID var contactRef = new ContactReference(interactionIdOne); Sitecore.XConnect.InteractionReference interactionRef = new Sitecore.XConnect.InteractionReference(contactRef, interactionIdTwo);

// Contact reference from identifier var identifiedContactRef = new IdentifiedContactReference("twitter", "myrtlesitecore"); Sitecore.XConnect.InteractionReference secondInteractionRef = new Sitecore.XConnect.InteractionReference(identifiedContactRef, Guid.Parse("E6067926-1F45-E611-82E6-34E6D7117DCB"));

var references = new List<Sitecore.XConnect.InteractionReference>() { interactionRef, secondInteractionRef };

IReadOnlyCollection<IEntityLookupResult> interactions = client.Get(references, new InteractionExecutionOptions(new InteractionExpandOptions() { })); } catch (Exception ex) { // Manage exceptions } } } } }

インタラクションのリストを要求する場合、返還タイプはコンタクトのリストではなく操作結果のリストとなります。返還タイプはReadOnlyCollection<IEntityLookupResult>です。このコレクションをループする際、各EntityLookupResultオブジェクトのEntityプロパティを通じてInteractionオブジェクト自体にアクセスできます。推奨される方法は、Interactionがnullかどうか、またはエンティティがExistsかどうかを確認することです。関連する操作結果の対応Exceptionも利用可能です。

シングルコンタクトの場合は .GetContactAsync() 方式を使えます。複数のコンタクトが入る場合は、.GetAsync() の方が性能が良いので使うのが良いです。

インタラクションイベントを取得

インタラクションは常に利用可能なすべてのイベントで再利用されます。さまざまなイベントの対応については「 インタラクションイベントの取得 」を参照してください。

交流や関連連絡の機会を得る

デフォルトでは、インタラクションはファセットや関連する連絡先なしで返されます。展開オプションを使って、どのファセットや連絡先情報を返すべきかを判断します:

この記事を改善するための提案がある場合は、 お知らせください!