Announcements
No record found.
using System; using System.Linq; using Microsoft.Xrm.Sdk; using Microsoft.Xrm.Sdk.Query; public class OpportunityCreatePlugin : IPlugin { public void Execute(IServiceProvider serviceProvider) { // 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); // The InputParameters collection contains all the data passed in the message request. if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity) { // Obtain the target entity from the input parameters. Entity entity = (Entity)context.InputParameters["Target"]; // Verify that the target entity represents an opportunity. if (entity.LogicalName != "opportunity") return; if (entity.Attributes.Contains("description")) { // Get the description field value. string description = entity.Attributes["description"]; // Split the description into GUIDs. string[] guids = description.Split(','); // Check if we have three GUIDs. if (guids.Length == 3) { foreach (string guid in guids) { // Parse the GUID. Guid userGuid = new Guid(guid.Trim()); // Create a reference to the user. EntityReference userRef = new EntityReference("systemuser", userGuid); // Create a new relationship entity record. Entity relationship = new Entity("new_opportunity_sales_team"); relationship["new_opportunityid"] = entity.ToEntityReference(); relationship["new_userid"] = userRef; // Create the relationship entity record. service.Create(relationship); } } } } } }
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.
Congratulations to our 2026 Super Stars!
We are thrilled to have these Champions in our Community!
These are the community rock stars!
Stay up to date on forum activity by subscribing.
11manish 165
ManoVerse 161 Super User 2026 Season 1
Zhilan 49