Part 19 - Understanding Basic Plugin Code Structure
Scenario:
==> You are working in a hospital using Dynamics 365 CRM.
==> Whenever a Patient record is created, you want to check if the patient’s age is less than 18 years.
==> If the patient is under 18, the system should show an error.
Step by Step Process of Writing a Basic Plugin Code:
1. Using Libraries:
2. Class and Plugin Declaration:
3. Main Execute Method:
4. Get Context (To Know What Happened):
Context ---> It tells you what triggered the plugin
Example:
5. Get Tracing Service (For Logs)
Example:
Recommended by LinkedIn
6. Check if It’s a Create Operation:
Example:
7. Get Patient Data:
8. Ensure It’s a Patient Record:
Example:
9. Check for Age Field:
10. Perform the Age Check:
Example:
===> By combining all the above steps the final plugin code look like as shown below:
Final Summary