locked
Attaching QuoteDetails into a Custom Entity RRS feed

  • Question

  • Hello,

    We're using CRM 2013 on-premise and our requirements are as follow:

    1. When a quote is activated, create a new custom entity 'Request'

    2. Associate the quote with the new Request entity

    3. Associate the new Request entity with all of the Quote Products from the Quote.

    I got #1 and #2 working successfully.

    However when I try to associate the newly created Request entity with quotedetail I got this error message: "The detail cannot be updated because the parent is not editable".

    Does it mean that it's not possible to attach quotedetail into any other entities?

    This is my code:

     var quoteProducts = service.RetrieveMultiple(new FetchExpression(string.Format(RetrieveQuoteProducts, requestId)));
                if (quoteProducts != null && quoteProducts.Entities.Count >= 1)
                {
                    foreach (Entity product in quoteProducts.Entities)
                    {
                        var productId = product.Id;
    
                        var productRequestReferenceCollection = new EntityReferenceCollection();
                        var productRequestRelatedEntity = new EntityReference
                        {
                            Id = productId,
                            LogicalName = "quotedetail"
                        };
                        productRequestReferenceCollection.Add(productRequestRelatedEntity);
                        var productRequestReferenceCollectionRelRelationship = new Relationship
                        {
                            SchemaName = Schema.QuoteProduct.ContractProductRelationship
                        };
                        service.Associate("new_Request", RequestId, productRequestReferenceCollectionRelRelationship, productRequestReferenceCollection);
                    }
                }

    Thanks much.

    -tri

    Thursday, November 5, 2015 10:45 PM

Answers

  • Hi,

    I found that this cannot be achieved when the quote is already in Activated status. We have to write a custom plugin to activate the quote, do all of the needed requirements, associate the needed records, then finally activate the quote at the very end.

    Thanks.

    -tri

    • Marked as answer by triangular Monday, November 9, 2015 5:31 PM
    Monday, November 9, 2015 5:31 PM