Hi,
Here is the sample code snippet:
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xrm.Sdk;
namespace PluginDemo {
public class Phonecall : IPlugin {
public void Execute(IServiceProvider serviceProvider) {
// Extract the tracing service for use in debugging sandboxed plug-ins.
ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
// Obtain the execution context from the service provider.
IPluginExecutionContext context = (IPluginExecutionContext) serviceProvider.GetService(typeof(IPluginExecutionContext));
// Obtain the organization service reference.
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
if (context.Depth == 1) {
if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity) {
Entity phonecall = (Entity)context.InputParameters["Target"];
phonecall["statuscode"] = 2;
service.Update(phonecall);
}
}
else {
return;
}
}
}
}
There are two different statuses will be marked as Completed in Phone Call entity.
The value of Made is 2 and the value of Received is 4.

And here is the documentation about how to register the plug-in in Dynamics 365.
Tutorial: Write and register a plug-in (Microsoft Dataverse) - Power Apps | Microsoft Docs
If this helped you, I'd appreciate it if you'd mark this as a Verified Answer, which may in turn help others as well.
Best Regards,
Nya