1

これを AdxStudio フォーラムに投稿したところ、まったく反応がなかったので、これのデバッグを手伝ってくれることを願っています。

次のように、CrmEntityFormView を使用して CRM で新しい連絡先を作成しています。

<adx:CrmDataSource ID="FormViewDataSource" runat="server" />
    <adx:CrmEntityFormView runat="server" ID="UserCreateForm" EntityName="contact" FormName="User Edit Form" DataSourceID="FormViewDataSource"
        RecommendedFieldsRequired="true" ValidationGroup="NewUser" ValidationText="* This field is required" EnableValidationSummaryLinks="false" 
        OnItemInserting="UserCreateForm_ItemInserting" OnItemInserted="UserCreateForm_ItemInserted">
        <InsertItemTemplate></InsertItemTemplate>
</adx:CrmEntityFormView>

<asp:Button ID="SubmitButton" Text='Create User' CssClass="button" ValidationGroup="NewUser" runat="server" OnClick="SubmitButton_Click" />

SubmitButton_Click ハンドラーを使用して、フォーム上の他のフィールドを次のように同時に処理しています。

 protected void SubmitButton_Click(object sender, EventArgs e)
 {
    if (!Page.IsValid)
        {
            return;
        }

    # Handle other form fields not on the FormView ...
    UserCreateForm.InsertItem();
 }

有効なフォームを送信しても、データベースで何も起こりません。そこで、ItemInserted イベントをデバッグし、ハンドラーの 1 行にブレークポイントを設定しました。

    protected void UserCreateForm_ItemInserted(object sender, CrmEntityFormViewInsertedEventArgs e)
    {
        Contact newUser = XrmContext.ContactSet.Where(c => c.ContactId == e.EntityId).FirstOrDefault();
    }

このイベントでは、e.Exception は null ではなく、タイトルからの SaveChangesException のインスタンスであり、「この要求の処理中にエラーが発生しました」というメッセージが表示されます。および e.ExceptionHandled == true です。これが、何も見たことがない理由だと思います。

この例外には、InnerException のインスタンスがあります。System.ServiceModel.FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault>

FormView の最初のフィールドの送信された値を常に含むメッセージを使用します。これが機能しない理由がまったくわかりません。また、これをさらにデバッグする方法も不明で、いくつかのポインターを使用できます。

4

1 に答える 1

1

The System.ServiceModel.FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault> eats the stack trace. Refer to this blog as a method to actually log the stacktrace to be able to find where your error is occurring.

于 2014-11-07T21:17:55.833 に答える