2

別のルックアップ フィールドの値に従ってアカウント エンティティの所有者を変更する Microsoft Dynamics CRM 4 用のプラグインを作成しています。これで、アカウントの「所有者」として機能するユーザーの GUID を取得できました。ここまでは順調ですね。所有者を変更しようとすると問題が発生します。AssignRequest を使用しようとしていますが、機能していません。リクエストを実行しようとすると、C# デバッガーで SoapException が発生し、Web サービスが次のようなダイアログを出力します。

以下は私が使用しているコードです:

                    TargetOwnedAccount target = new TargetOwnedAccount();

                    SecurityPrincipal assignee = new SecurityPrincipal();
                    assignee.Type = SecurityPrincipalType.User;
                    assignee.PrincipalId = context.InitiatingUserId;

                    target.EntityId = ownerGuid; //this is the GUID I am retrieving from the other lookup field

                    AssignRequest assign = new AssignRequest();
                    assign.Assignee = assignee;
                    assign.Target = target;

                    AssignResponse res = (AssignResponse)crmService.Execute(assign); //this is where i get the exception

何も見逃していないことを願っています。どんな助けでも大歓迎です:)ありがとう

4

1 に答える 1

2

わかりました私は最終的にこれを解決することができました。それは私の顔をじっと見つめていました :P 間違った場所に間違った ID を入力していました。「assignee.PrincipalId」を「ownerGuid」に設定し、「target.EntityId」を現在のアカウント ID に設定する必要がありました。新しいコードは次のとおりです。

                TargetOwnedAccount target = new TargetOwnedAccount();

                SecurityPrincipal assignee = new SecurityPrincipal();
                assignee.Type = SecurityPrincipalType.User;
                assignee.PrincipalId = ownerGuid; //this is the GUID I am retrieving from the other lookup field

                target.EntityId = ((Key)entity.Properties["accountid"]).Value;

                AssignRequest assign = new AssignRequest();
                assign.Assignee = assignee;
                assign.Target = target;

                AssignResponse res = (AssignResponse)crmService.Execute(assign);

昨日は8時間も見ていたなんて信じられないけど、今日はすぐに気づいた :P

于 2012-07-31T08:09:26.420 に答える