BPM - creating copy of same module

Every year, we create a renewal quote for customers.  When customers accept a quote (denoted by changing the quote stage), we'd like to use BPM to create a copy of the quote (and the quote line items) for next year.  Unfortunately, BPM only lets you create a "related" record.  Since we're triggering the activity on the "Quote" module, it does not appear in the choices.

If anyone can point us to documents/website/video that explains how to create a copy of the quote along with the quote line items, I would appreciate it very mch.

Thank you!

  • Hi Bob!

    We had a similar requirement for opportunities, and logic hooks are probably the best approach here, since this involves multiple modules (eg: Quotes, Line Items). Requires a bit of coding but it's simple. 

    Step 1: Create a logic hook, like in this example:

    https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_10.1/Cookbook/Logic_Hooks/Comparing_Bean_Properties_Between_Logic_Hooks/`

    Eg:

    
    $hook_array['after_save'][] = Array(1,'Quote for Next Year','custom/modules/Quotes/CreateQuoteForNextYear.php', 'CreateQuoteForNextYear','execute',);
    

    Step 2: When the Quote stage is "Accepted", add logic to copy the Quote & line items for next year, by copying the current quote into the new quote object. Here is a rough script that does that, needs some fine tuning per your requirements:

    
    // Clone Quote
    $newQuote = clone $currentQuote;
    $newQuote->description = 'For Next Year';
    
    // Load existing product bundles
    $currentQuote->load_relationship('product_bundles');
    $currentProductBundles = $currentQuote->product_bundles->getBeans();
    
    foreach ($currentProductBundles as $currentBundle) {
        // Create new product bundle
        $newProductBundle = clone $currentBundle;
    
        // Create products
        $currentProducts = $currentBundle->get_products();
        foreach($currentProducts as $currentProduct) {
            $newProduct = clone $currentProduct;
            $newProductBundle->products->add($newProduct);
        }
    
        // Add the bundle to the quote
        $newQuote->product_bundles->add($newProductBundle);    
        
    }
    
    // Done!
    $newQuote->save();
    

    Step 3: If you're using cloud, you may want to create a package for deployment, please follow the steps as described in this sugar documentation: https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_9.2/Cookbook/Module_Loadable_Packages/Creating_an_Installable_Package_for_a_Logic_Hook/

    Blue heart from Seven Tunes Labs

  • In Sugar Sell 10.1, a new feature was introduced which addresses this need, but similar to Neeraja, it is at the Opportunity level as opposed to Quote. Basically, if you have an Opportunity which includes renewable Revenue Line Items (e.g. a subscription), Sugar will detect that when you mark the Opp as Closed Won, and generate you a new Opp for next year (or however long your service runs for).

    https://support.sugarcrm.com/Documentation/Sugar_Versions/10.1/Sell/Application_Guide/Opportunities/#Services_and_Renewable_Revenue_Line_Items

  • This can also be done with an ETL tool such as StarfishETL or Sugar Integrate.  If you already have an integration using an ETL tool, you can likely add this job on with little or no cost.  Have the ETL tool monitor for newly Closed Won Quotes and when it finds one, read out the Quote and any related records, like QLIs, and then insert a new Quote with new related records based on the original.  You can even add a checkbox or other conditional criteria if you only want certain Quotes duplicated.

  • This new feature is really nice and I hope it makes its way to the Quotes module.  I'd like to see the Opportunity and Quote modules tied much more closely together to remove some of the repetitive data entry required to keep Opportunities and Quotes in sync.

  • Thank you .  I was hoping to be able to do this without coding but I will explore your solution - it looks like it's do-able.  I appreciate the time you spent in responding.

  • Thank you, Adam & Justin!

  • ,

    When using RLI (Revenue Line Items), from an Opportunity, it is possible to create the matching Quote.

    1- open Opportunity record

    2- navigate to RLI subpanel

    3- select all RLI that you want to quote for

    4- click on "Generate Quote"

    5- save the record

    Hope it helps

    --

    Enrico Simonetti

    Sugar veteran (from 2007)

    www.naonis.tech


    Feel free to reach out for consulting regarding:

    • API Integration and Automation Services
    • Sugar Architecture
    • Sugar Performance Optimisation
    • Sugar Consulting, Best Practices and Technical Training
    • AWS and Sugar Technical Help
    • CTO-as-a-service
    • Solutions-as-a-service
    • and more!

    All active SugarCRM certifications

    Actively working remotely with customers based in APAC and in the United States

  • Hi ,

    The problem is that after the Quote is worked, modified and Won, users have to manually update the Opportunity to reflect the state of the Closed Won Quote.  This manual process is tedious and leads to errors.

  • Some of these new features, and data structures, have encouraged me to rethink the way "we've always done it" in Sugar. I know a number of customers where exactly what you've described is what occurs - and we used to set up logic hooks to address it.

    However, using the feature that Enrico described, it is possible that I might start advising a different flow,i.e.

    1. Generate the quote as per his directions.
    2. If the client requires changes to line items, make those changes at the Opp>RLI level
    3. Generate a new quote to reflect the current state of line items
    4. Repeat steps 2-3 until Quote is accepted

    In this way, the Opp already reflects the latest state of the Quote, i.e. are in sync. The other ideal part of this is that the intended logic around creating renewal opportunities will flow perfectly down - since RLIs are already at their latest state.