<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://sugarclub.sugarcrm.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>How to reference the Discount field when creating a BPM?</title><link>https://sugarclub.sugarcrm.com/explore/help-forums/enterprise-professional/f/enterprise-professional-questions/8293/how-to-reference-the-discount-field-when-creating-a-bpm</link><description>Hi! 
 
 The discount field seems not to carry over to a renewable RLI/Opportunity. I tried to create a BPM but I cant reference the Discount field. is there a way that we can carry over the values in the original RLI to the renewables for the discount</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: How to reference the Discount field when creating a BPM?</title><link>https://sugarclub.sugarcrm.com/thread/33569?ContentTypeID=1</link><pubDate>Thu, 04 Dec 2025 11:29:41 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:92c45072-0ce9-4832-8330-0fe328004481</guid><dc:creator>Andre Serrazina</dc:creator><description>&lt;p&gt;Hello &lt;a href="/members/kendrickcapilla343225"&gt;Kendrick Capilla&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;br /&gt;&lt;em&gt;&lt;br /&gt;&lt;/em&gt;Thanks for this question.&amp;nbsp;&lt;/p&gt;
&lt;p class="p1"&gt;I looked into the code, and it turns out that &lt;i&gt;discount_amount&lt;/i&gt; is not included when Sugar automatically creates the new renewal Revenue Line Item (RLI) after the existing one is moved to &lt;span class="s1"&gt;&lt;b&gt;Closed Won&lt;/b&gt;&lt;/span&gt;.&lt;/p&gt;
&lt;p class="p1"&gt;Here&amp;rsquo;s the full list of fields that Sugar copies to the&amp;nbsp;new RLI when the Original renewable RLI is closed-won:&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;$copyRliFields&lt;/span&gt;&lt;span&gt; = [&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;&amp;#39;name&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;&amp;#39;account_id&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;&amp;#39;product_template_id&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;&amp;#39;category_id&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;&amp;#39;tax_class&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;&amp;#39;likely_case&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;&amp;#39;currency_id&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;&amp;#39;base_rate&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;&amp;#39;quantity&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;&amp;#39;list_price&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;&amp;#39;cost_price&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;&amp;#39;discount_price&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;&amp;#39;renewable&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;&amp;#39;service&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;&amp;#39;service_duration_value&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;&amp;#39;service_duration_unit&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;&amp;#39;catalog_service_duration_value&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;&amp;#39;catalog_service_duration_unit&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;&amp;#39;assigned_user_id&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;&amp;#39;team_id&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;&amp;#39;team_set_id&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;&amp;#39;acl_team_set_id&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt; ];&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Unfortunately, from what I can see there isn&amp;rsquo;t a way to include discount_amount using BPM alone on the new RLI generation process.&lt;br /&gt;&lt;br /&gt;Based on my review, the only way to achieve this is through a customization: &lt;a href="https://support.sugarcrm.com/documentation/sugar_developer/sugar_developer_guide_25.1/data_framework/models/sugarbean/customizing_core_sugarbeans/#Extending_the_SugarBean"&gt;extending the Opportunities SugarBean&lt;/a&gt; and creating your own version of the createNewRenewalRLI() function that replicates the original function and includes the additional field.&lt;br /&gt;&lt;br /&gt;It&amp;rsquo;s a fairly straightforward customization, but of course, it does require development resources, and I understand that may not always be available. &lt;br /&gt;&lt;br /&gt;Still, I wanted to share the approach for reference in case it&amp;rsquo;s helpful.&lt;br /&gt;&lt;br /&gt;If you do go down the customization route, you would need to create two files:&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;p class="p1"&gt;&lt;span class="s1"&gt;&lt;b&gt;1.&lt;/b&gt;&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;custom/modules/Opportunities/Opportunity.php&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="php"&gt;&amp;lt;?php

require_once &amp;#39;modules/Opportunities/Opportunity.php&amp;#39;;

class CustomOpportunity extends Opportunity
{

    //this is acopy of the original createNewRenewalRLI() adding the field discount_amount to  $copyRliFields

    public function createNewRenewalRLI(RevenueLineItem $rli): RevenueLineItem
    {
        $copyRliFields = [
            &amp;#39;name&amp;#39;,
            &amp;#39;account_id&amp;#39;,
            &amp;#39;product_template_id&amp;#39;,
            &amp;#39;category_id&amp;#39;,
            &amp;#39;tax_class&amp;#39;,
            &amp;#39;likely_case&amp;#39;,
            &amp;#39;currency_id&amp;#39;,
            &amp;#39;base_rate&amp;#39;,
            &amp;#39;quantity&amp;#39;,
            &amp;#39;list_price&amp;#39;,
            &amp;#39;cost_price&amp;#39;,
            &amp;#39;discount_price&amp;#39;,
            &amp;#39;discount_amount&amp;#39;,
            &amp;#39;renewable&amp;#39;,
            &amp;#39;service&amp;#39;,
            &amp;#39;service_duration_value&amp;#39;,
            &amp;#39;service_duration_unit&amp;#39;,
            &amp;#39;catalog_service_duration_value&amp;#39;,
            &amp;#39;catalog_service_duration_unit&amp;#39;,
            &amp;#39;assigned_user_id&amp;#39;,
            &amp;#39;team_id&amp;#39;,
            &amp;#39;team_set_id&amp;#39;,
            &amp;#39;acl_team_set_id&amp;#39;,
        ];

        $newRliBean = BeanFactory::newBean($rli-&amp;gt;getModuleName());
        $timeDate = TimeDate::getInstance();
        $newStartDate = $timeDate-&amp;gt;fromDbDate($rli-&amp;gt;service_end_date)-&amp;gt;modify(&amp;#39;+1 day&amp;#39;)-&amp;gt;asDbDate();
        $newRliBean-&amp;gt;service_start_date = $newStartDate;
        $newRliBean-&amp;gt;date_closed = $newStartDate;
        $newRliBean-&amp;gt;product_type = &amp;#39;Existing Business&amp;#39;;
        $newRliBean-&amp;gt;opportunity_id = $this-&amp;gt;id;
        $newRliBean-&amp;gt;renewal = true;

        foreach ($copyRliFields as $field) {
            if (isset($rli-&amp;gt;$field)) {
                $newRliBean-&amp;gt;$field = $rli-&amp;gt;$field;
            }
        }

        $newRliBean-&amp;gt;save();

        if ($this-&amp;gt;load_relationship(&amp;#39;revenuelineitems&amp;#39;)) {
            $this-&amp;gt;revenuelineitems-&amp;gt;add($newRliBean);
        }

        return $newRliBean;
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;h3 id="mcetoc_1jbkhb4qp1"&gt;&lt;/h3&gt;
&lt;p class="p1"&gt;&lt;span class="s1"&gt;&lt;b&gt;2.&lt;/b&gt;&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;custom/Extension/application/Ext/Include/customOpportunity.php&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="php"&gt;&amp;lt;?php
/**
 * Map Opportunities to use the CustomOpportunity class
 */

// Only needed if not already defined, but safe to include:
$objectList[&amp;#39;Opportunities&amp;#39;] = &amp;#39;Opportunity&amp;#39;;

// Tell Sugar to use CustomOpportunity as the bean class
$beanList[&amp;#39;Opportunities&amp;#39;] = &amp;#39;CustomOpportunity&amp;#39;;

// Point to the file you just created
$beanFiles[&amp;#39;CustomOpportunity&amp;#39;] = &amp;#39;custom/modules/Opportunities/CustomOpportunity.php&amp;#39;;&lt;/pre&gt;&lt;/p&gt;
&lt;h3 id="mcetoc_1jbkhsqt72"&gt;&lt;/h3&gt;
&lt;p&gt;Let us know if this helps.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Cheers,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Andr&amp;eacute;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h3 id="mcetoc_1jbkg494s0"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/h3&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>