I am facing an issue with GenerateQuoteFromOpportunityRequest,
I have created an action that calls a new plugin the only thing this plugin does is call generate a quote from an opportunity using GenerateQuoteFromOpportunityRequest, the issue is when an opportunity contains only 300 items the process takes more then 2min which intern causes the plugin the fail....
Is there a better way to do this from a plugin?
using System;
using System.Linq;
using System.Text;
using Microsoft.Xrm.Sdk;
using System.Net;
using Microsoft.Xrm.Sdk.Query;
using System.IO;
using System.Runtime.Serialization.Json;
using System.Collections.Generic;
using Microsoft.Xrm.Sdk.Messages;
using System.ServiceModel;
using Microsoft.Crm.Sdk.Messages;
namespace ex_Dynamics365_Plugins
{
public class exRecordCreateOrDeletePlugin : IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{
// Get tracing service for debugging purposes
ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
//tracingService.Trace("exRecordCreateOrDeletePlugin - called");
// Get the context of the message
IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService dynamicsService = serviceFactory.CreateOrganizationService(context.UserId);
tracingService.Trace("exRecordCreateOrDeletePlugin - called");
Entity opportunity = new Entity();
if (context.InputParameters.Contains("opportunity")) {
opportunity = (Entity)context.InputParameters["opportunity"];
}
tracingService.Trace("exRecordCreateOrDeletePlugin - paramaters set");
if (context.MessageName.Equals("ex_CreateQuoteAction")) {
Entity new_quote;
tracingService.Trace("ex_CreateQuoteAction - GenerateQuoteFromOpportunityRequest");
GenerateQuoteFromOpportunityRequest req = new GenerateQuoteFromOpportunityRequest();
req.OpportunityId = opportunity.Id;
req.ColumnSet = new ColumnSet(true);
tracingService.Trace("ex_CreateQuoteAction - Execute GenerateQuoteFromOpportunityRequest");
GenerateQuoteFromOpportunityResponse resp = ((GenerateQuoteFromOpportunityResponse)dynamicsService.Execute(req));
tracingService.Trace("ex_CreateQuoteAction - define new new_quote based on the response");
new_quote = resp.Entity;
new_quote["totalamount"] = 0;
dynamicsService.Update(new_quote);
}
else
{
tracingService.Trace("exRecordCreateOrDeletePlugin - no action specified");
}
}
}
}
Hi RynaCRM,
It will be done but needs some Research and Development.
Thanks
Regards,
Abdul Wahab
Power Platform/Customer Engagement Developer/Lead/Solution Architecture/Project Manager
Direct/WhatsApp:+923323281237
E-mail: abdulwahabubit@outlook.com
Skype: abdul.wahabubit
i dont suppose you have an example of how i could trigger this using the webapi ? / or if it is possible to do this?
Hi RyanCRM,
This is not possible using a plugin/custom workflow extension. You need to power automate or call some other service...
Let me know if I can provide you with more details.
Thanks
Regards,
Abdul Wahab
Power Platform/Customer Engagement Developer/Lead/Solution Architecture/Project Manager
Direct/WhatsApp:+923323281237
E-mail: abdulwahabubit@outlook.com
Skype: abdul.wahabubit
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156