locked
Object quote cannot be converted to Quote Close RRS feed

  • Question

  • Hi everyone,

    I am trying to change quote state(actually i am trying to win the quote, my quote state is active by now) on CRM 4.0.  Here is what i wrote :


                string myQuoteId = "21EA4808-5BCF-DE11-8C03-000C299C4A38";

                ColumnSet set = new ColumnSet();
                set.Attributes = new string[] { "quoteid" };
                BusinessEntity myDet = myCrmService.Retrieve(EntityName.quote.ToString(), new Guid(myQuoteId), set);
                quote updateQuote = (quote)myDet;

                try
                {
                    CloseQuoteRequest myReq = new CloseQuoteRequest();
                    myReq.QuoteClose = myDet;
                    myReq.Status = 4;

                    CloseQuoteResponse myResp = new CloseQuoteResponse();
                    myResp = (CloseQuoteResponse)myCrmService.Execute(myReq);
                }
                catch (System.Web.Services.Protocols.SoapException ex)
                {
                    throw ex;
                }
    But every time i tried i got the same error in crm Trace :

    [2009-11-12 10:25:24.4] Process: w3wp |Organization:2128e70d-89b1-de11-bed1-000c299c4a38 |Thread:   10 |Category: Platform |User: 3036c656-1abc-de11-9a19-000c299c4a38 |Level: Error | MessageProcessor.Execute
    >MessageProcessor fail to process message 'Close' for 'quote'.
    [2009-11-12 10:25:24.4] Process: w3wp |Organization:2128e70d-89b1-de11-bed1-000c299c4a38 |Thread:   10 |Category: Platform.Sdk |User: 3036c656-1abc-de11-9a19-000c299c4a38 |Level: Error | CompositeSoapExtensionExceptionHandler.Handle
    >CrmSoapExtension detected non-CrmException - report will be sent to Watson:
    System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.ArgumentException: Object of type 'Microsoft.Crm.Entities.Quote' cannot be converted to type 'Microsoft.Crm.Entities.QuoteClose'.

    I have already tried SetStateQuoteRequest, WinQuoteRequest, SetStateCloseQuoteRequest classes. But none of them worked either. Does anybody has any ideas ? I am stucked. Thanx a lot. have a nice day...


    1 and 0's. That's all the problem...
    Thursday, November 12, 2009 8:46 AM

Answers

  • Hi,

    your assignment is wrong. You have to use a quoteclose instance.

    quoteclose qc = new quoteclose();
    qc.subject = _quote.Subject;
    qc.quoteid = CrmTypes.CreateLookup("quote", {quote id});
    
    WinQuoteRequest wqr = new WinQuoteRequest();
    wqr.QuoteClose = qc;
    wqr.Status = 4;
    
    service.Execute(wqr);
    • Marked as answer by burak_gvn Thursday, November 12, 2009 9:49 AM
    Thursday, November 12, 2009 9:15 AM

All replies

  • Hi,

    your assignment is wrong. You have to use a quoteclose instance.

    quoteclose qc = new quoteclose();
    qc.subject = _quote.Subject;
    qc.quoteid = CrmTypes.CreateLookup("quote", {quote id});
    
    WinQuoteRequest wqr = new WinQuoteRequest();
    wqr.QuoteClose = qc;
    wqr.Status = 4;
    
    service.Execute(wqr);
    • Marked as answer by burak_gvn Thursday, November 12, 2009 9:49 AM
    Thursday, November 12, 2009 9:15 AM
  • pass status as -1 and this might resolve the issue..


      string myQuoteId = "21EA4808-5BCF-DE11-8C03-000C299C4A38";

                ColumnSet set = new ColumnSet();
                set.Attributes = new string[] { "quoteid" };
                BusinessEntity myDet = myCrmService.Retrieve(EntityName.quote.ToString(), new Guid(myQuoteId), set);
                quote updateQuote = (quote)myDet;

                try
                {
                    CloseQuoteRequest myReq = new CloseQuoteRequest();
                    myReq.QuoteClose = myDet;
                    myReq.Status = -1;

                    CloseQuoteResponse myResp = new CloseQuoteResponse();
                    myResp = (CloseQuoteResponse)myCrmService.Execute(myReq);
                }
                catch (System.Web.Services.Protocols.SoapException ex)
                {
                    throw ex;
                }

    Thursday, November 12, 2009 9:18 AM
    Answerer
  • Thanx a lot mate, that was really helpfull. Have a nice day...
    1 and 0's. That's all the problem...
    Thursday, November 12, 2009 9:49 AM