{"id":606,"date":"2020-04-28T17:58:29","date_gmt":"2020-04-28T17:58:29","guid":{"rendered":"http:\/\/morecpq.com\/?p=606"},"modified":"2020-04-28T17:58:30","modified_gmt":"2020-04-28T17:58:30","slug":"advanced-approval-submit-multiple-records-in-related-list-classic","status":"publish","type":"post","link":"https:\/\/morecpq.com\/index.php\/2020\/04\/28\/advanced-approval-submit-multiple-records-in-related-list-classic\/","title":{"rendered":"Advanced Approval &#8211; Submit Multiple Records in Related List (Classic)"},"content":{"rendered":"\n<p>A new Code Using Advance Approvals <\/p>\n\n\n\n<p>If you created a new approval process with Advanced Approvals package and you need a quick way to submit for approval multiple records from selecting them from a Related list (without having to enter each record), this code will work very well for you. <\/p>\n\n\n\n<p>For this Project we have the Advance Approval in SBQQ__QuoteLine__c Object and the final behavior is that from the quote we can select the quote lines and send them for approval.<\/p>\n\n\n\n<p>We are going to create a button of type List Button (JavaScript):<\/p>\n\n\n\n<p>1. Creare a New Apex Class: Setup &#8211;&gt; Click on your Name &#8211;&gt; Developer Console AutoSubmit<\/p>\n\n\n\n<p><code>global\u00a0class\u00a0AutoSubmit{<br>\u00a0\u00a0\u00a0\u00a0webService\u00a0static\u00a0void\u00a0processAutoSubmission(Id\u00a0QLId){<br>\u00a0\u00a0\u00a0\u00a0\u00a0\/\/In each quote line<br>\u00a0\u00a0\u00a0\u00a0\u00a0\/\/Set&lt;string&gt;\u00a0QLineIds\u00a0=\u00a0new\u00a0Set&lt;string&gt;();<br>\u00a0\u00a0\u00a0\u00a0\u00a0\/\/QLineIds.add(QLId);<br>     \/\/Call the Submit package class<br>\u00a0\u00a0\u00a0\u00a0\u00a0SBAA.ApprovalAPI.submit(QLId,\u00a0SBAA__Approval__c.Quote_Line__c);<br>\u00a0\u00a0\u00a0\u00a0}}<\/code><\/p>\n\n\n\n<p>2. Create a New Button: Setup &#8211;&gt; Objects &#8211;&gt; Quote Line &#8211;&gt; New Button or Link<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Label: Test &#8211; Submit<\/li><li>Display Type: List Button<\/li><li>Display Checkboxes (for Multi-Record Selection): TRUE<\/li><li>Behavior: Execute JavaScript<\/li><li>Content Source: OnClick JavaScript<\/li><li>Body: <\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>{!REQUIRESCRIPT(\"\/soap\/ajax\/48.0\/connection.js\")}\n{!REQUIRESCRIPT(\"\/soap\/ajax\/48.0\/apex.js\")}\nvar selectedLines = {!GETRECORDIDS($ObjectType.SBQQ__QuoteLine__c)};\nvar linesForUpdate = &#091;];\nif(selectedLines&#091;0] == null){\n   alert(\"You must select at least one record\");\n}else{\n    for(var i = 0; i&lt;selectedLines.length; i++){\n       \n       var quoteLin = sforce.SObject(\"SBQQ__QuoteLine__c\");\n       var quoteLin = selectedLines&#091;i];\n       quoteLin.Id = selectedLines&#091;i];\n\n       var message = sforce.apex.execute(\"AutoSubmit\",\"processAutoSubmission\",{QLId:quoteLin});\n    }\n}\nlocation.reload(true);<\/code><\/pre>\n\n\n\n<p>3. Add the List Button in the Quote Page Layout in the Quote Line related list:<br>Setup &#8211;&gt; Objects &#8211;&gt; Quote &#8211;&gt; Page Layout &#8211;&gt; Quote Line Related List &#8211;&gt; Button for Properties <br><img data-recalc-dims=\"1\" decoding=\"async\" width=\"651\" height=\"508\" class=\"wp-image-616\" style=\"width: 450px\" src=\"https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2020\/04\/Captura-de-pantalla-2020-04-28-a-las-11.57.53-a.-m..png?resize=651%2C508\" alt=\"\" srcset=\"https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2020\/04\/Captura-de-pantalla-2020-04-28-a-las-11.57.53-a.-m..png?w=651&amp;ssl=1 651w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2020\/04\/Captura-de-pantalla-2020-04-28-a-las-11.57.53-a.-m..png?resize=300%2C234&amp;ssl=1 300w\" sizes=\"(max-width: 651px) 100vw, 651px\" \/> <br>Save.<\/p>\n\n\n\n<p>Final Behavior: What you should observe at the end is the button available in the related list and the checkboxes for you to select the lines that you are going to send for approval.<br><img data-recalc-dims=\"1\" decoding=\"async\" width=\"940\" height=\"286\" class=\"wp-image-618\" style=\"width: 800px\" src=\"https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2020\/04\/Captura-de-pantalla-2020-04-28-a-las-12.29.13-p.-m..png?resize=940%2C286\" alt=\"\" srcset=\"https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2020\/04\/Captura-de-pantalla-2020-04-28-a-las-12.29.13-p.-m..png?w=1207&amp;ssl=1 1207w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2020\/04\/Captura-de-pantalla-2020-04-28-a-las-12.29.13-p.-m..png?resize=300%2C91&amp;ssl=1 300w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2020\/04\/Captura-de-pantalla-2020-04-28-a-las-12.29.13-p.-m..png?resize=1024%2C311&amp;ssl=1 1024w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2020\/04\/Captura-de-pantalla-2020-04-28-a-las-12.29.13-p.-m..png?resize=768%2C234&amp;ssl=1 768w\" sizes=\"(max-width: 940px) 100vw, 940px\" \/><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A new Code Using Advance Approvals If you created a new approval process with Advanced Approvals package and you need a quick way to submit for approval multiple records from selecting them from a Related list (without having to enter each record), this code will work very well for you. For this Project we have &hellip;<br \/><a href=\"https:\/\/morecpq.com\/index.php\/2020\/04\/28\/advanced-approval-submit-multiple-records-in-related-list-classic\/\" class=\"more-link pen_button pen_element_default pen_icon_arrow_double\">Continue reading <span class=\"screen-reader-text\">Advanced Approval &#8211; Submit Multiple Records in Related List (Classic)<\/span><\/a><\/p>\n","protected":false},"author":3,"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":[59,60,58,62,61],"class_list":["post-606","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-advancedapprovals","tag-approvals","tag-cpq-2","tag-javascript","tag-js"],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/posts\/606","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\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/comments?post=606"}],"version-history":[{"count":11,"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/posts\/606\/revisions"}],"predecessor-version":[{"id":619,"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/posts\/606\/revisions\/619"}],"wp:attachment":[{"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/media?parent=606"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/categories?post=606"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/tags?post=606"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}