Skip to content

Return the concrete type of OrganizationResponses #272

Description

@SvenRahnSIT

The CRM returns custom API responses as the correct type when early bound entities/messages are present with the corresponding RequestProxyAttribute and ResponseProxyAttribute (just use the early bound generator v2 from the XrmToolbox to generate those). This is working correctly in the CRM:

var response = service.Execute(new someRequest());
var typedResponse = (someResponse)response;

This only works when the request and response types annotated with the proces attributes are present. FakeXrmEasy doesn't do this. I register a custom API like this:

context.RegisterPluginStep<SomeCustomAPI>(new PluginStepDefinition()
{
    MessageName = "whatever",
    Stage = FakeXrmEasy.Abstractions.Plugins.Enums.ProcessingStepStage.Postoperation,
});

FakeXrmEasy just returns an OrganizationResponse. Is there any way to make FXE to return the concrete type like the CRM does?

An example of a generated request and response:

[System.Runtime.Serialization.DataContractAttribute(Namespace="http://schemas.microsoft.com/xrm/2011/new/")]
[Microsoft.Xrm.Sdk.Client.RequestProxyAttribute("sit_some_custom_api")]
public partial class SomeRequest: Microsoft.Xrm.Sdk.OrganizationRequest
{
	
	public static class Fields
	{
		public const string returnAll = "returnAll";
	}
	
	public const string ActionLogicalName = "sit_some_custom_api";
	
	public bool? returnAll
	{
		get
		{
			if (this.Parameters.Contains("returnAll"))
			{
				return ((bool)(this.Parameters["returnAll"]));
			}
			else
			{
				return default(bool);
			}
		}
		set
		{
			this.Parameters["returnAll"] = value;
		}
	}
	
	public SomeRequest()
	{
		this.RequestName = "sit_some_custom_api";
	}
}

[System.Runtime.Serialization.DataContractAttribute(Namespace="http://schemas.microsoft.com/xrm/2011/new/")]
[Microsoft.Xrm.Sdk.Client.ResponseProxyAttribute("sit_some_custom_api")]
public partial class SomeResponse: Microsoft.Xrm.Sdk.OrganizationResponse
{
	
	public static class Fields
	{
		public const string classifications = "classifications";
	}
	
	public const string ActionLogicalName = "sit_some_custom_api";
	
	public SomeResponse()
	{
	}
	
	public Microsoft.Xrm.Sdk.EntityCollection? classifications
	{
		get
		{
			if (this.Results.Contains("classifications"))
			{
				return ((Microsoft.Xrm.Sdk.EntityCollection)(this.Results["classifications"]));
			}
			else
			{
				return default(Microsoft.Xrm.Sdk.EntityCollection);
			}
		}
		set
		{
			this.Results["classifications"] = value;
		}
	}
}

Activity

  1. SvenRahnSIT commented on Aug 19, 2026

    @SvenRahnSIT
    Author

    Ah, well, I solved the issue. My MessageExecutor returned an OrganizationResponse instead of the concrete type.

  2. jordimontana82 commented on Aug 21, 2026

    @jordimontana82
    Contributor

    Oh, ok yes, makes sense, glad you sorted it out @SvenRahnSIT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions