简体   繁体   中英

CRM C# Close Quote Request : “An unexpected error occurred.”

I need to close the quote in a plugin and I am sure that the quote's status(statecode) is active(not draft).I am using Close Quote Request Message as shown below.

        CloseQuoteRequest closeQuoteRequest = new CloseQuoteRequest()
        {
             QuoteClose=quote,
             Status=new OptionSetValue(5)
        };

       service.Execute(closeQuoteRequest);

When i execute the request, it throws error message:'An unexpected error occurred'. Then I found another approach but in that approach, I cant use CloseQuote class under Crm.Sdk.Messages namespace.

 CloseQuoteRequest closeQuoteRequest = new CloseQuoteRequest()
 {
    QuoteClose = new QuoteClose()
    {
       QuoteId = closeQuote.ToEntityReference(),
       Subject = "Accepted " + DateTime.Now.ToString()
    },

   Status = new OptionSetValue(5),
  }; 

How can I use QuoteClose class or what's wrong with first code block that cause an error?

As far as I understood in first code part you were passing quote entity instance to QuoteClose parameter of Request. This is wrong because you have to pass QuoteClose entity instance. Recheck following article - http://mileyja.blogspot.com/2011/08/close-quote-using-jscript-or-net-in.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM