In Dynamics 365, you may want to perform an Organization Request in a piece of custom code in order to trigger an Action, or perform an undocumented SDK operation.
The Dynamics 365 SDK comes with the Organization Request class, which all Organization Requests in the SDK are derived from. This class can also be used to execute custom requests, as it can take in the name of a request, and the parameters for the request as a series of key-value pairs. These can be added to the Organization Request in a couple of different ways (shown below).
This can then be executed in the normal manner through use of the .execute method of the IOrganizationService. The SDK will construct the request, and will automatically detect the parameter types from the .NET types passed in to the class, and will use these when constructing the request.
After sending this off, the response is returned as a corresponding Organization Response object, which can then be interpreted to get the status of the operation performed and any output from the request – this may be in the form of output parameters when using this functionality to trigger actions etc.
Aside from triggering Actions, this functionality can also be used to call a number of CRM messages – including messages for internal use only. While it is not officially supported to call these internal CRM messages using the Organization Request class, it remains that it is possible to do so. There is a rather comprehensive list of messages available to call via this functionality here:
https://msdn.microsoft.com/en-us/library/gg309482(v=crm.8).aspx, with a further few here:
There may also be other undocumented messages that are available to be called using this functionality, but this will not be officially supported.
A variety of functions can be performed, for example, publishing customisations: