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 :
Microsoft Dynamics CRM (Archived)

Throw an exception on custom Message(Action)

(0) ShareShare
ReportReport
Posted on by

 8037.action.JPG

 

 

 

{

    public class QuoteFinalPricingAcceptHandler : IPluginEventHandler

    {

                public void DoExecute(LocalPluginContext localContext)

        {

Try

{

                var service = localContext.OrganizationService;

 

                Guid quoteId = localContext.PluginExecutionContext.InputParameters[QuoteFinalPricingAcceptActionParameters.InQoutationId].ChangeType<Guid>();

 

                Entity quoteClose = new Entity(QuoteCloseEntityAttributeNames.EntityLogicalName);

                quoteClose.Attributes.Add(QuoteCloseEntityAttributeNames.Subject, "Quote Close" + DateTime.Now.ToString());

                quoteClose.Attributes.Add(QuoteCloseEntityAttributeNames.QuoteId, new EntityReference(QuoteEntityAttributeNames.EntityLogicalName, quoteId));

 

                WinQuoteRequest wonQuote = new WinQuoteRequest()

                {

                    QuoteClose = quoteClose,

                    Status = new OptionSetValue((int)QuoteStatus.Won),

                    RequestName = "WinQuote"

                };

                WinQuoteResponse responseExe = (WinQuoteResponse)service.Execute(wonQuote);

 

                ColumnSet salesOrderColumns = new ColumnSet(OrderEntityAttributeNames.OrderId, OrderEntityAttributeNames.TotalAmount);

 

                ConvertQuoteToSalesOrderRequest convertQuoteRequest = new ConvertQuoteToSalesOrderRequest()

                {

                    QuoteId = quoteId,

                    ColumnSet = salesOrderColumns

                };

 

                ConvertQuoteToSalesOrderResponse convertQuoteResponse = (ConvertQuoteToSalesOrderResponse)service.Execute(convertQuoteRequest);

                SalesOrder salesOrder = (SalesOrder)convertQuoteResponse.Entity;

                string serializedResponse = JsonConvert.SerializeObject(salesOrder.SalesOrderId);

                localContext.PluginExecutionContext.OutputParameters[QuoteFinalPricingAcceptActionParameters.OutCreatedSalesOrderId] = serializedResponse;

 

            }

            catch(Exception e)

            {

                throw new InvalidPluginExecutionException(“Error”);

            }       

}

    }

}

 

 

On above action (custom message), calling above code and trying to through exception. Exception is not triggering on error. This action is calling ribbon button and I need to show error message to user on error on action. Please suggest how to though error on Global action.

*This post is locked for comments

I have the same question (0)

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 > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans