{"id":735,"date":"2021-02-08T14:47:02","date_gmt":"2021-02-08T14:47:02","guid":{"rendered":"http:\/\/morecpq.com\/?p=735"},"modified":"2023-11-21T10:41:30","modified_gmt":"2023-11-21T15:41:30","slug":"cpq-orphaned-amendments-solution","status":"publish","type":"post","link":"https:\/\/morecpq.com\/index.php\/2021\/02\/08\/cpq-orphaned-amendments-solution\/","title":{"rendered":"CPQ &#8211; Orphaned Amendments &#8211; Solution!"},"content":{"rendered":"\n<p>There came an issue with amendment Opportunities\/Quotes being orphaned after a renewal was closed won and Contracted!  Below is a diagram showing the issue.  <\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized is-style-default\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"940\" height=\"504\" src=\"https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/02\/Renewal-Object-Relationship.png?resize=940%2C504&#038;ssl=1\" alt=\"\" class=\"wp-image-745\" style=\"width:580px;height:311px\" srcset=\"https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/02\/Renewal-Object-Relationship.png?resize=1024%2C549&amp;ssl=1 1024w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/02\/Renewal-Object-Relationship.png?resize=300%2C161&amp;ssl=1 300w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/02\/Renewal-Object-Relationship.png?resize=768%2C411&amp;ssl=1 768w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/02\/Renewal-Object-Relationship.png?w=1400&amp;ssl=1 1400w\" sizes=\"(max-width: 940px) 100vw, 940px\" \/><\/figure>\n\n\n\n<p>The process is as follows:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Everything is fine (most important step)<\/li>\n\n\n\n<li>Create new Opportunity\n<ol class=\"wp-block-list\">\n<li>New Quote<\/li>\n<\/ol>\n<\/li>\n\n\n\n<li>Close win Opportunity <\/li>\n\n\n\n<li>Click Contracted = True on Opportunity (or your favorite automation)\n<ol class=\"wp-block-list\">\n<li>Contract is auto-created<\/li>\n\n\n\n<li>Subscriptions are auto-created<\/li>\n<\/ol>\n<\/li>\n\n\n\n<li>Click Renewal Forecast\/Quoted on Contract (or your favorite automation)\n<ol class=\"wp-block-list\">\n<li>Renewals are auto-created<\/li>\n<\/ol>\n<\/li>\n\n\n\n<li>Then we begin an Amendment on the Contract\n<ol class=\"wp-block-list\">\n<li>Click Amend and Amend on the Contract<\/li>\n\n\n\n<li>Save the Quote<\/li>\n<\/ol>\n<\/li>\n\n\n\n<li>Then we go back to the Renewal Opportunity and close win it!  BEFORE the Amendment Opportunity is completed&#8230;<\/li>\n\n\n\n<li>Click Contracted = True on the Renewal Opportunity (or your favorite automation)\n<ol class=\"wp-block-list\">\n<li>New Contract is auto-created<\/li>\n\n\n\n<li>Subscriptions are auto-created<\/li>\n<\/ol>\n<\/li>\n\n\n\n<li>This is where the problem lies. Now, we have an in-flight Amendment on the old Contract that we do not wanna have to recreate on the new Contract.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"940\" height=\"319\" src=\"https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/02\/Renewal_Amendment-Process-Flow.png?resize=940%2C319&#038;ssl=1\" alt=\"\" class=\"wp-image-746\" style=\"width:572px;height:193px\" srcset=\"https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/02\/Renewal_Amendment-Process-Flow.png?resize=1024%2C347&amp;ssl=1 1024w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/02\/Renewal_Amendment-Process-Flow.png?resize=300%2C102&amp;ssl=1 300w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/02\/Renewal_Amendment-Process-Flow.png?resize=768%2C261&amp;ssl=1 768w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2021\/02\/Renewal_Amendment-Process-Flow.png?w=1120&amp;ssl=1 1120w\" sizes=\"(max-width: 940px) 100vw, 940px\" \/><\/figure>\n\n\n\n<p>Here is the proposed solution process.  Once the system creates the new Contract and Subscriptions, another process is kicked off that reassigns the in-flight amendment Opportunity\/Quote\/Quote Lines to the new Contract\/Subscriptions.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><em>Custom Setting and Fieldset Design<\/em><\/h4>\n\n\n\n<p>The idea for Settings and Fieldset comes from the notion that this solution should not need maintenance after it is implemented.&nbsp; Therefore we give Settings and a Metadata Type to allow for adjustments to the process.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><em>Custom Setting Definition<\/em><\/h4>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>Custom Setting<\/strong><\/td><td><strong>Purpose<\/strong><\/td><\/tr><tr><td><strong>On\/Off<\/strong><\/td><td>The <strong>On\/Off<\/strong> setting allows for control over if the automation runs or not, in the event any of the risks are being experienced.<\/td><\/tr><tr><td><strong>Amendment Opp Stage(s)<\/strong><\/td><td>The <strong>Amendment Opp Stage(s)<\/strong> setting will determine which amendments to reassign to the new Contract.<\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\">Make sure to insert a record into this custom setting after creating it!<\/figcaption><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><em>Fieldset Definition<\/em><\/h4>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>Object<\/strong><\/td><td><strong>Fieldset Name<\/strong><\/td><td><strong>Purpose<\/strong><\/td><\/tr><tr><td><strong>Quote Line<\/strong><\/td><td><strong>Reassigned Amendment Fields<\/strong><\/td><td>The <strong>Reassigned Amendment Fields<\/strong> fieldset on the Quote Line object will control which fields to copy from renewal Subscription -&gt; Quote Line to existing amendment Quote Line.<\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\">Make sure to add fields to this fieldset after creating it!<\/figcaption><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><em>Process Logic Design<\/em><\/h4>\n\n\n\n<p>The logic of this new process will be implemented in a future method.&nbsp; This is to mitigate any potential heap size or timeout limit issues as much as possible.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Trigger Mechanism: Flow Scheduled Action\n<ol class=\"wp-block-list\">\n<li>Flow: Contract :: On After Create\n<ol class=\"wp-block-list\">\n<li>Criteria: No Criteria<\/li>\n\n\n\n<li>SCHEDULED ACTION\n<ol class=\"wp-block-list\">\n<li>Schedule: 0 Days After CreatedDate<\/li>\n\n\n\n<li>Action: Call Apex\n<ol class=\"wp-block-list\">\n<li>Action Name: ReassignAmendments<\/li>\n\n\n\n<li>Apex Class: ContractTriggerHelper<\/li>\n\n\n\n<li>Set Apex Variables: contractIds = Field Reference: [Contract].Id<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<\/li>\n\n\n\n<li>If the <strong>On\/Off Setting<\/strong> is TRUE and the Contract -> Opportunity -> Renewed Contract != NULL,\n<ol class=\"wp-block-list\">\n<li>Query for necessary fields from the passed in contracts.<\/li>\n\n\n\n<li>Query for Opportunities that have:\n<ol class=\"wp-block-list\">\n<li>Account = Account on Contract that fired this process<\/li>\n\n\n\n<li>Amended Contract = this Contract -&gt; Opportunity -&gt; Renewed Contract<\/li>\n\n\n\n<li>Is not closed with Stage = Amendment Opp Stage(s) setting<\/li>\n<\/ol>\n<\/li>\n\n\n\n<li>Query for Primary Quotes that have Opportunity in the above list of Opportunity IDs.<\/li>\n\n\n\n<li>Query for Subscriptions of the new (renewal) Contract (that fired this process).<\/li>\n\n\n\n<li>Query for fields to update on reassigned amendment quote lines.<\/li>\n\n\n\n<li>Query for quote lines of the above renewal subscriptions.<\/li>\n\n\n\n<li>Query for amendment Quote Lines that have Quote = above list of Quote IDs.<\/li>\n\n\n\n<li>Loop through these contracts.\n<ol class=\"wp-block-list\">\n<li>Loop through amendment Opportunities.\n<ol class=\"wp-block-list\">\n<li>If this Opportunity -> amended Contract == this Contract -> Opportunity -> renewed Contract\n<ol class=\"wp-block-list\">\n<li>Set this amendment Opportunity -&gt; Amended Contract = New (renewal) Contract<\/li>\n\n\n\n<li>Loop through amendment Quotes.\n<ol class=\"wp-block-list\">\n<li>Set this Quote -&gt; Master Contract = New (renewal) Contract (that fired this process)<\/li>\n\n\n\n<li>Loop through new (renewal) Subscriptions (of the Contract that fired this process).\n<ol class=\"wp-block-list\">\n<li>Loop through amendment Quote Lines\n<ol class=\"wp-block-list\">\n<li>If this renewal Subscription -> Quote Line -> Renewed Subscription == this amendment Quote Line -> Upgraded Subscription,\n<ol class=\"wp-block-list\">\n<li>Set this amendment Quote Line -&gt; Upgraded Subscription = this new renewal Subscription.<\/li>\n\n\n\n<li>Loop through Reassigned Amendment Fields fieldset\u2019s fields.\n<ol class=\"wp-block-list\">\n<li>Set this amendment Quote Line -&gt; this fieldset field = this new renewal Subscription -&gt; Quote Line -&gt; this fieldset field value.<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<\/li>\n\n\n\n<li>Save Amendment Quote Lines<\/li>\n\n\n\n<li>Save Amendment Quotes<\/li>\n\n\n\n<li>Save Amendment Opps<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n\n\n\n<p>And now you&#8217;re at the end!  Of this post.  Which means you get a prize.  This is on the AppExchange.  Go install it.  \ud83d\ude42 <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/appexchange.salesforce.com\/appxListingDetail?listingId=f26aca4c-2cea-49c6-862b-2ea3cd81c44e\" target=\"_blank\" rel=\"noreferrer noopener\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"451\" height=\"313\" src=\"https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2023\/11\/image.png?resize=451%2C313&#038;ssl=1\" alt=\"\" class=\"wp-image-2556\" srcset=\"https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2023\/11\/image.png?w=451&amp;ssl=1 451w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2023\/11\/image.png?resize=300%2C208&amp;ssl=1 300w\" sizes=\"(max-width: 451px) 100vw, 451px\" \/><\/a><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>There came an issue with amendment Opportunities\/Quotes being orphaned after a renewal was closed won and Contracted! Below is a diagram showing the issue. The process is as follows: Here is the proposed solution process. Once the system creates the new Contract and Subscriptions, another process is kicked off that reassigns the in-flight amendment Opportunity\/Quote\/Quote &hellip;<br \/><a href=\"https:\/\/morecpq.com\/index.php\/2021\/02\/08\/cpq-orphaned-amendments-solution\/\" class=\"more-link pen_button pen_element_default pen_icon_arrow_double\">Continue reading <span class=\"screen-reader-text\">CPQ &#8211; Orphaned Amendments &#8211; Solution!<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-735","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/posts\/735","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/comments?post=735"}],"version-history":[{"count":35,"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/posts\/735\/revisions"}],"predecessor-version":[{"id":2557,"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/posts\/735\/revisions\/2557"}],"wp:attachment":[{"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/media?parent=735"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/categories?post=735"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/tags?post=735"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}