web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

Update the Phone Call status as Complete with the C# plugin code.

(0) ShareShare
ReportReport
Posted on by

Please help me to update the Phone Call entity record status as Complete with the C# plugin code.

I have the same question (0)
  • Suggested answer
    meelamri Profile Picture
    13,216 User Group Leader on at

    Hi, 

    Please refer to the snippet code: 

                Entity phoneCallRecord = new Entity("phonecall", new Guid("A837237F-B5A1-EB11-B1AC-000D3A38BEBC"));
                phoneCallRecord["statecode"] = new OptionSetValue(1);
                phoneCallRecord["statuscode"] = new OptionSetValue(2);
                crmSvc.Update(phoneCallRecord);
    

  • Suggested answer
    Nya Profile Picture
    29,060 on at

    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.

     pastedimage1618910813294v1.png

    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

  • Esteban Coto Alfaro Profile Picture
    on at

    Hello, in the following link there is an example of how to create and edit a record of an entity, in this case a "contact", however you can adapt it to the entity "phonecall": carldesouza.com/.../.

    In the following link comes the information corresponding to the entity "phonecall" with the names of the properties, the type of data and the details: docs.microsoft.com/.../phonecall

    And I also attach the documentation of the "contact" entity that could be of help: docs.microsoft.com/.../contact

    Thanks!

    Community Support Team - Esteban
    If this Post helps, then please consider Accept as solution to help the other members find it more quickly.

  • Suggested answer
    Dheeraj Raghav Profile Picture
    on at

    Thank you for your help.

  • Nya Profile Picture
    29,060 on at

    Hi,

    If there is any further question about the code, please feel free to follow up and please verify the answer by clicking Yes if it has been solved.

     

    Best Regards,

    Nya

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 137 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 57

#3
Jimmy Passeti Profile Picture

Jimmy Passeti 50 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans