{"id":1326,"date":"2022-04-11T16:39:18","date_gmt":"2022-04-11T16:39:18","guid":{"rendered":"https:\/\/morecpq.com\/?p=1326"},"modified":"2022-05-20T15:11:56","modified_gmt":"2022-05-20T15:11:56","slug":"mdq-amendment-ordering-error-cant-activate-an-order-with-partially-segmented-order-items","status":"publish","type":"post","link":"https:\/\/morecpq.com\/index.php\/2022\/04\/11\/mdq-amendment-ordering-error-cant-activate-an-order-with-partially-segmented-order-items\/","title":{"rendered":"MDQ &#8211; Amendment Ordering &#8211; Error: Can&#8217;t activate an order with partially segmented order items"},"content":{"rendered":"\n<p>If you&#8217;re here, you probably are trying to activate an Order against an amendment on a Quote that has MDQ lines.  Did I get that right? \ud83d\ude42  There&#8217;s an <a href=\"https:\/\/trailblazer.salesforce.com\/issues_view?id=a1p3A000001YpWMQA0&amp;title=mdq-segment-with-0-quantity-does-not-create-an-order-product-and-prevents-order-from-being-activated\" target=\"_blank\" rel=\"noreferrer noopener\">existing bug report<\/a> that has not been addressed yet at Salesforce&#8230;<\/p>\n\n\n\n<p>And you may have also come across <a rel=\"noreferrer noopener\" href=\"https:\/\/trailhead.salesforce.com\/trailblazer-community\/feed\/0D54S00000A8UZXSA3\" target=\"_blank\">this article<\/a> explaining a work around by <a rel=\"noreferrer noopener\" href=\"https:\/\/trailblazers.salesforce.com\/profileView?u=0053A00000FLZ7NQAX\" target=\"_blank\">@Kyle Trebotich<\/a>.  If you haven&#8217;t checked his profile out, definitely do so.  Quite a great CPQ powerhouse.  <\/p>\n\n\n\n<p>His work around is to null out the three Segment fields on all the order lines and THEN clicking activate.  This is great!  But&#8230; what about all of the existing orders that have already been created?  Do I have to manually do this every time I want to order against an MDQ amendment?  NOPE!  Below is a solution to get your existing orders ready for activation as well as a solution for future orders so you don&#8217;t have to think about this anymore.  \ud83d\udc4d\ud83c\udffb  <\/p>\n\n\n\n<p>The fields we are concerned with are on the OrderItem object.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"725\" height=\"170\" src=\"https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2022\/03\/Snip-Order-Product-Salesforce.png?resize=725%2C170&#038;ssl=1\" alt=\"\" class=\"wp-image-1330\" srcset=\"https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2022\/03\/Snip-Order-Product-Salesforce.png?w=725&amp;ssl=1 725w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2022\/03\/Snip-Order-Product-Salesforce.png?resize=300%2C70&amp;ssl=1 300w\" sizes=\"(max-width: 725px) 100vw, 725px\" \/><\/figure>\n\n\n\n<p><strong>New Field &#8211; Order Object<\/strong><\/p>\n\n\n\n<p>To support the below solution, you&#8217;ll need to create a custom field for Quote Type on the Order object.  This will tell us if a given Order is the result of an Amendment Quote.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"835\" height=\"476\" src=\"https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2022\/04\/Snip-Object-Manager-Salesforce.png?resize=835%2C476&#038;ssl=1\" alt=\"\" class=\"wp-image-1368\" srcset=\"https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2022\/04\/Snip-Object-Manager-Salesforce.png?w=835&amp;ssl=1 835w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2022\/04\/Snip-Object-Manager-Salesforce.png?resize=300%2C171&amp;ssl=1 300w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2022\/04\/Snip-Object-Manager-Salesforce.png?resize=768%2C438&amp;ssl=1 768w\" sizes=\"(max-width: 835px) 100vw, 835px\" \/><\/figure>\n\n\n\n<p><strong>General One Order &#8211; Autolaunched Flow<\/strong><\/p>\n\n\n\n<p>First, we need a flow that handles one Order!  Here are the steps the flow takes:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Autolaunched flow: Input is an Order ID.<\/li><li>Retrieve the Order using Order ID and criteria is amendment Quote and not Activated.<\/li><li><span style=\"color: initial;\">Create &#8220;Lines to Update&#8221; record set.<\/span><\/li><li>If we have an Order,<ol><li>Get lines for this Order that has Segment fields filled in.<\/li><li>Loop through the lines.<ol><li>Blank out Segment fields.<\/li><li>Add this line to the &#8220;<span style=\"color: initial;\">Lines to Update<\/span>&#8221; record set.<\/li><\/ol><\/li><\/ol><\/li><li>Return the &#8220;<span style=\"color: initial;\">Lines to Update<\/span>&#8221; record set.<\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"451\" height=\"821\" src=\"https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2022\/03\/Snip-Fix-MDQ-Order-Lines-V1.png?resize=451%2C821&#038;ssl=1\" alt=\"\" class=\"wp-image-1347\" srcset=\"https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2022\/03\/Snip-Fix-MDQ-Order-Lines-V1.png?w=451&amp;ssl=1 451w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2022\/03\/Snip-Fix-MDQ-Order-Lines-V1.png?resize=165%2C300&amp;ssl=1 165w\" sizes=\"(max-width: 451px) 100vw, 451px\" \/><\/figure>\n\n\n\n<p><strong>Existing in-flight Orders &#8211; Manual Update<\/strong><\/p>\n\n\n\n<p>Once we have this invocable flow, we can make a flow to query all non-Activated Orders and update them.<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Invocable flow: no input.<\/li><li>Retrieve all non-Activated Orders against amendment Quotes.<\/li><li>Create &#8220;<span style=\"color: initial;\">Lines to Update<\/span>&#8221; record set.<\/li><li>Loop through the Orders.<ol><li>Call above invocable flow.<\/li><li>Set the output of the above flow to the &#8220;<span style=\"color: initial;\">Lines to Update<\/span>&#8221; record set.<\/li><\/ol><\/li><li>If we have <span style=\"color: initial;\">Lines to Update<\/span>,<ol><li>Update the lines.<\/li><\/ol><\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"399\" height=\"922\" src=\"https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2022\/04\/Snip-Autolaunched-Fix-Existing-MDQ-Order-Lines-V1.png?resize=399%2C922&#038;ssl=1\" alt=\"\" class=\"wp-image-1363\" srcset=\"https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2022\/04\/Snip-Autolaunched-Fix-Existing-MDQ-Order-Lines-V1.png?w=399&amp;ssl=1 399w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2022\/04\/Snip-Autolaunched-Fix-Existing-MDQ-Order-Lines-V1.png?resize=130%2C300&amp;ssl=1 130w\" sizes=\"(max-width: 399px) 100vw, 399px\" \/><\/figure>\n\n\n\n<p>Now, we have a flow to update all in-flight non-Activated Orders to blank out the Segment fields of the MDQ OrderItems.  We need to call it.  You can just run the flow from the flow designer.  \ud83d\udc4d\ud83c\udffb <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"940\" height=\"76\" src=\"https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2022\/04\/Snip-Autolaunched-Fix-Existing-MDQ-Order-Lines-V1-2.png?resize=940%2C76&#038;ssl=1\" alt=\"\" class=\"wp-image-1365\" srcset=\"https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2022\/04\/Snip-Autolaunched-Fix-Existing-MDQ-Order-Lines-V1-2.png?resize=1024%2C83&amp;ssl=1 1024w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2022\/04\/Snip-Autolaunched-Fix-Existing-MDQ-Order-Lines-V1-2.png?resize=300%2C24&amp;ssl=1 300w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2022\/04\/Snip-Autolaunched-Fix-Existing-MDQ-Order-Lines-V1-2.png?resize=768%2C62&amp;ssl=1 768w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2022\/04\/Snip-Autolaunched-Fix-Existing-MDQ-Order-Lines-V1-2.png?w=1182&amp;ssl=1 1182w\" sizes=\"(max-width: 940px) 100vw, 940px\" \/><\/figure>\n\n\n\n<p><strong>Future Orders &#8211; Amendment Screen Flow<\/strong><\/p>\n\n\n\n<p>Now, for future Orders, we need a flow that triggers off a new &#8220;Amend&#8221; button for the Contract.<\/p>\n\n\n\n<p>Here&#8217;s the flow:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Screen Flow: Input: recordId<\/li><li>Show screen to input Amendment Start Date value.<\/li><li>Next Button<\/li><li>Update Contract record.<\/li><li>Forward to CPQ Amend screen.<\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2022\/04\/Snip-Screen-Amend-Contract-V17.png?resize=143%2C510&#038;ssl=1\" alt=\"\" class=\"wp-image-1411\" width=\"143\" height=\"510\" srcset=\"https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2022\/04\/Snip-Screen-Amend-Contract-V17.png?w=224&amp;ssl=1 224w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2022\/04\/Snip-Screen-Amend-Contract-V17.png?resize=84%2C300&amp;ssl=1 84w\" sizes=\"(max-width: 143px) 100vw, 143px\" \/><\/figure>\n\n\n\n<p>Here is the button (Lightning Action):  Make sure to add the below Action to your Lightning Page!<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"822\" height=\"285\" src=\"https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2022\/04\/Snip-Contract-Salesforce-2.png?resize=822%2C285&#038;ssl=1\" alt=\"\" class=\"wp-image-1412\" srcset=\"https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2022\/04\/Snip-Contract-Salesforce-2.png?w=822&amp;ssl=1 822w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2022\/04\/Snip-Contract-Salesforce-2.png?resize=300%2C104&amp;ssl=1 300w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2022\/04\/Snip-Contract-Salesforce-2.png?resize=768%2C266&amp;ssl=1 768w\" sizes=\"(max-width: 822px) 100vw, 822px\" \/><\/figure>\n\n\n\n<p><strong>Installer<\/strong><\/p>\n\n\n\n<p>You&#8217;ve reached the end so, as always, here is an installer for all the things above.  \ud83d\ude42  Make sure to add the Action to your Lightning Page!<\/p>\n\n\n\n<p><a href=\"https:\/\/test.salesforce.com\/packaging\/installPackage.apexp?p0=04t4x000000lzFF&amp;isdtp=p1\" target=\"_blank\" rel=\"noreferrer noopener\">Sandbox<\/a> | <a href=\"https:\/\/login.salesforce.com\/packaging\/installPackage.apexp?p0=04t4x000000lzFF&amp;isdtp=p1\" target=\"_blank\" rel=\"noreferrer noopener\">Production<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you&#8217;re here, you probably are trying to activate an Order against an amendment on a Quote that has MDQ lines. Did I get that right? \ud83d\ude42 There&#8217;s an existing bug report that has not been addressed yet at Salesforce&#8230; And you may have also come across this article explaining a work around by @Kyle &hellip;<br \/><a href=\"https:\/\/morecpq.com\/index.php\/2022\/04\/11\/mdq-amendment-ordering-error-cant-activate-an-order-with-partially-segmented-order-items\/\" class=\"more-link pen_button pen_element_default pen_icon_arrow_double\">Continue reading <span class=\"screen-reader-text\">MDQ &#8211; Amendment Ordering &#8211; Error: Can&#8217;t activate an order with partially segmented order items<\/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-1326","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\/1326","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=1326"}],"version-history":[{"count":47,"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/posts\/1326\/revisions"}],"predecessor-version":[{"id":1518,"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/posts\/1326\/revisions\/1518"}],"wp:attachment":[{"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/media?parent=1326"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/categories?post=1326"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/tags?post=1326"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}