Capability | Custom Action | Custom API |
---|---|---|
Create Or Modify using a solution | No | Yes |
Bind Operation to entity collection | No | Yes |
Bind Operation to the entity | Yes | Yes |
Create global operation | Yes | Yes |
Create Odata function | No | Yes |
Making message private | No | Yes |
Block extension by another plugin | No | Yes |
Require specific privileges | No | Yes |
Scenario:
We need a custom API that needs to count the number of characters in a string and it should be only allowed to the user having privilege "prvReadAccount".
- Create a solution and add a new "Custom API"
Fill attributes as below
- Binding Type: Global (Since we do not want to bind to an entity)
- Is Function: No (We are creating an action which takes a parameter in the body and can be called using the POST method)
- Allow custom processing step type: This defines which type of plugin can be registered on custom API. We have selected none so we don't want anyone else to register on custom api.
- Execute Privilege Name: "prvReadAccount" (Calling user must have this privilege if left blank user privilege is not checked).
- Plugin Type: Keep blank for now, need to select the plugin type once we deploy our plugin.
2. Define custom API request parameter
I have created a parameter with the name "instring" of type string.
3. Define custom API response parameter
I have created a parameter with the name "charCount" of type string.
4. Create Plugin
Here we are checking if MessageName is "new_countcharacters" and performing the action.
Now as we have created the plugin, let's go ahead and register it.
After registering the plugin we need to update Custom Api for "Plugin Type"
Testing Custom Api (I am using CRM rest builder of testing)
Hope this was helpful, Happy learning.
0 Comments