tyoshikawa1106のブログ

- Force.com Developer Blog -

SFDC:EventRelationとShared Activitiesの有効化

行動に招待された人の情報はEventRelationオブジェクトに格納されます。

f:id:tyoshikawa1106:20161103210158p:plain

EventRelation


このEventRelationについてDiscussionForumで気になる投稿がありました。Shared Activitiesを有効化するとリレーションの項目の対象オブジェクトが変更されるみたいです。


有効化前は取引先責任者の情報が表示されます。
f:id:tyoshikawa1106:20161103210611p:plain


Shared Activitiesの有効化すると契約オブジェクトを検索するようになるみたいです。有効化して確認してみました。有効化は活動の設定から行うことができます。
f:id:tyoshikawa1106:20161103210813p:plain


確認してみるとたしかに契約オブジェクトに切り替わっていました。
f:id:tyoshikawa1106:20161103211037p:plain


EventRelationオブジェクトですがShared Activitiesの有効化を行うと使える項目が増えるみたいです。
f:id:tyoshikawa1106:20161103212251p:plain


inputFieldをつかって少し強引に表示してみました。
f:id:tyoshikawa1106:20161103212326p:plain


他のオブジェクトのようにinputFieldを使って気軽に入力フォームは作れないみたいです。


次のようなデータを作ってどのように登録されているか確認してみました。
f:id:tyoshikawa1106:20161103213354p:plain

f:id:tyoshikawa1106:20161103213415p:plain


実行クエリはこんな感じです。

SELECT Id,EventId,Status,RelationId,Response,RespondedDate,AccountId,IsParent,IsWhat
FROM EventRelation WHERE EventId ='00UG000000sN2d0'


RelationIdにはきちんと取引先責任者IDが登録できているみたいです。
f:id:tyoshikawa1106:20161103213515p:plain


開発者ガイドを見るとShared Activitiesの有効化前と後の値の更新方法について少し触れられていました。
f:id:tyoshikawa1106:20161103212548p:plain


リレーション項目のルックアップが契約オブジェクトになっていたのは不思議ですが、一応Shared Activitiesの有効化後でも取引先責任者などを登録することはできると思います。(実際には試せていませんが..)


ちなみにShared Activitiesの無効化はセールスフォースのサポートに問い合わせる必要があるので有効化時には注意してください。
f:id:tyoshikawa1106:20161103211135p:plain

検証でつかったサンプルコード

<apex:page controller="EventRelationEditController" sidebar="false">
    <apex:form id="form">
        <apex:pageBlock id="block" mode="edit" title="EventRelation">
            <apex:pageBlockSection id="section">
                <apex:inputField value="{!eventRelation.EventId}" />
                <apex:inputField value="{!eventRelation.Status}" />
                <apex:inputField value="{!eventRelation.RelationId}" />
                <apex:inputField value="{!eventRelation.Response}" />
                <apex:inputField value="{!eventRelation.RespondedDate}" />
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Shared Activitiesを有効化後に利用できる項目">
                <apex:inputField value="{!eventRelation.AccountId}"/>
                <apex:inputField value="{!eventRelation.IsParent}" />
                <apex:inputField value="{!eventRelation.IsWhat}" />
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
public with sharing class EventRelationEditController {
    
    public EventRelation eventRelation {get; set;}
    
    public EventRelationEditController() {
        this.eventRelation = [
            SELECT
                 Id
                ,EventId
                ,Status
                ,RelationId
                ,Response
                ,RespondedDate
                ,AccountId
                ,IsParent
                ,IsWhat
            FROM
                EventRelation
            WHERE
                EventId ='00UG000000sN2d0'
            LIMIT 1
       ];
    }
}