There are 2 ways to create a custom message in Dataverse, one is through action, and the other is through Custom API.
Check the post on Custom API
Custom Process Action vs Custom API –
With custom process action we can define business logic using a workflow, and we can extend it using either custom workflow activities or registering the plugin.
If we are just defining action just for the custom message and then using plugin/custom workflow activity for defining all the logic (and not using workflow), it is recommended to use the Custom API feature instead.
Here however we will have a look at the way we had implemented global custom action for integration with the external system for any inbound call to CRM.
Below is our sample custom global action with one input and output parameter.
For the output parameter, we are setting the value in the step.
Next, we have 2 plugin steps registered one on the pre-validation stage and the other on post-operation.
Pre-validation because we want to run the logic outside the transaction, perform validation, log exceptions, etc.
Pre-validation example –
Post-operation because action’s output parameter would only be available in the post-operation and used Shared Variable to pass the custom response from pre-validation plugin to post-operation.
On executing the action
We get the following plugin trace logs as expected.
One for pre-validation
Hope it helps..