locked
Convert Opportunity to Order and its Related Entity Values RRS feed

  • Question

  • Hi All,

              I have a Requirement that i have Revenue Entity with 1:N relation ship with Opportuntiy. Revenue entity contains N number of Revenue for a Paticular Opportunity. 

              If i convert an Opportunity to an Order i need to map Opportunity fields with Order fields and the Revenue which they have mentioned should reflect the same in Order 

    Friday, November 7, 2014 11:57 AM

All replies

  • Hi,

    Create 1-N relation between sales order and Revenue. ( Sales Order --> Revenue)

    In Post create message of sales order check the context.ParentContext.MessageName if it is equal to GenerateSalesOrderFromOpportunity than set the salesorder lookup in Revenue entity with the created sales order.


    If you find this post helpful then please Vote as Helpful and Mark As Answer. Thanks and Regards, Polat Aydın My blog


    Friday, November 7, 2014 12:11 PM
  • Thanks polat, Please find my clear Requirement with screen shot.

    this is Opportuntiy with Revenue entity

    Below mentioned is an Order Entity

    If i convert Opportunity to Order i need to map the Opportunity entity values to the order values and i need to Create revenue Projection in Order, as how its in Opportunity with the same values as per Opportunity . Hope you can help in this. Please share the the code. Thanks in advance

    • Edited by JERRY_TP Friday, November 7, 2014 12:35 PM
    Friday, November 7, 2014 12:30 PM
  • Hi Jerry,

    You dont need to re-create revenue Projection record.As ı mentioned above , you can fill the sales order lookup value in Revenue Projection. It will be the  same Revenue Projection record both Opportunity and SalesOrder. 

    When you convert opportunity to order Crm executes GenerateSalesOrderFromOpportunityRequest background. And create a plugin in salesorder post-create message and use the code below

    string controls = String.Empty;
    
    if (context.ParentContext != null)
        {
    		controls = context.ParentContext.MessageName;
        }
    if (controls.ToLower() == "GenerateSalesOrderFromOpportunity".ToLower() )
        {
    		//select the Revenue Projection records with related the opportunity
    		//loop the Revenue Projection records and set the salesorder lookup in  Revenue Projection records with salesorderid that you created
         }


    If you find this post helpful then please Vote as Helpful and Mark As Answer. Thanks and Regards, Polat Aydın My blog


    Friday, November 7, 2014 12:56 PM