{"id":126,"date":"2019-03-06T21:32:40","date_gmt":"2019-03-06T21:32:40","guid":{"rendered":"http:\/\/morepalmer.org\/?p=126"},"modified":"2025-02-03T10:37:17","modified_gmt":"2025-02-03T15:37:17","slug":"generating-a-document-error-generating-document-bad-request","status":"publish","type":"post","link":"https:\/\/morecpq.com\/index.php\/2019\/03\/06\/generating-a-document-error-generating-document-bad-request\/","title":{"rendered":"Generating a Document: Error generating document: Bad Request"},"content":{"rendered":"\n<figure class=\"wp-block-image size-full is-resized\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"940\" height=\"522\" src=\"https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2022\/05\/image.webp?resize=940%2C522&#038;ssl=1\" alt=\"\" class=\"wp-image-1489\" style=\"width:410px;height:228px\" srcset=\"https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2022\/05\/image.webp?w=1024&amp;ssl=1 1024w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2022\/05\/image.webp?resize=300%2C167&amp;ssl=1 300w, https:\/\/i0.wp.com\/morecpq.com\/wp-content\/uploads\/2022\/05\/image.webp?resize=768%2C427&amp;ssl=1 768w\" sizes=\"(max-width: 940px) 100vw, 940px\" \/><\/figure>\n\n\n\n<p>If you&#8217;ve ever got this error when generating a document, you probably have less hair than you did before generating the document.<\/p>\n\n\n\n<p>There are multiple reasons this could happen:  <\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>HTML tags in a Quote Line Line Column field in the lines section Template Content.<\/li>\n\n\n\n<li>One of your HTML Template Content records has a reference to an image that has a bad SRC (does not exist, unable to load, no permission to access the image, etc).<\/li>\n\n\n\n<li>The markup inside your Custom VisualForce Page Template Content is bad.  Below is a list of supported tags per <a href=\"https:\/\/help.salesforce.com\/articleView?id=cpq_template_content_html.htm&amp;type=5\">this Salesforce article<\/a>.\n<ul class=\"wp-block-list\">\n<li><strong>Supported HTML Tags<\/strong>\n<ul class=\"wp-block-list\">\n<li>html<\/li>\n\n\n\n<li>br<\/li>\n\n\n\n<li>div<\/li>\n\n\n\n<li>p<\/li>\n\n\n\n<li>em<\/li>\n\n\n\n<li>li<\/li>\n\n\n\n<li>ol<\/li>\n\n\n\n<li>strike<\/li>\n\n\n\n<li>strong<\/li>\n\n\n\n<li>b<\/li>\n\n\n\n<li>i<\/li>\n\n\n\n<li>u<\/li>\n\n\n\n<li>ul<\/li>\n\n\n\n<li>a<\/li>\n\n\n\n<li>img<\/li>\n\n\n\n<li>span<\/li>\n\n\n\n<li>sub<\/li>\n\n\n\n<li>sup<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Supported HTML Tag Attributes<\/strong>\n<ul class=\"wp-block-list\">\n<li>style<\/li>\n\n\n\n<li>href<\/li>\n\n\n\n<li>src<\/li>\n\n\n\n<li>alt<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p><strong>HTML tags in a Quote Line Line Column Field<br><\/strong>You have a standard lines section.  You have a list of Line Columns on your Quote Template.  One of those Line Column fields on one or more of your Quote Line records on the offending Quote has a value that contains HTML tags.  A frequent culprit of this is the Description field.  It could also be some custom field you made and pulled into your template via a Line Column.<\/p>\n\n\n\n<p>What to do?  Do an export of the Fields from your Line Columns of the Quote Line records from the offending Quote.  You can do this with <a href=\"https:\/\/help.salesforce.com\/articleView?id=data_loader.htm&amp;type=5\">Data Loader<\/a> or with the <a href=\"https:\/\/help.salesforce.com\/articleView?id=code_dev_console_tab_query_editor.htm&amp;type=5\">Developer Console<\/a>.<\/p>\n\n\n\n<p><strong>The Image Thing<br><\/strong>You might have some HTML referencing an image that no longer existed or become corrupt (the url for the image just shows a blank page or some other corrupt image URL). Example:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;img alt=\"logo\" height=\"100\" src=\"https:\/\/mydomain--c.naXX.content.force.com\/servlet\/servlet.ImageServer?id=0151K0000040ptM&amp;oid=00D41000000FWOw\" width=\"180\" \/&gt;<\/pre>\n\n\n\n<p>What to do?  Create a new image and update the HTML to use the new URL.<\/p>\n\n\n\n<p>Also!  Do you have a Logo Document ID set on your Quote Template?  Check the document record for that ID and make sure it has Externally Available Image set to TRUE.<\/p>\n\n\n\n<p><strong>Custom VisualForce Page Template Content<br><\/strong>The markup of the content is bad.  You have to go in and make sure that all tags that are non -apex tags are not HTML but <a href=\"https:\/\/www.w3.org\/TR\/2006\/REC-xsl11-20061205\/\">XSL:FO<\/a> instead.<\/p>\n\n\n\n<p>Sometimes, when displaying rich text fields (such as Product Description) in a VisualForce Page Template Content, HTML tags are in the rich text.  But you can not have HTML tags.   <\/p>\n\n\n\n<p>What to do?  Put this in your controller:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ do this to replace all html tags in a rich text field.<br>richTextFieldValue = richTextFieldValue.replaceAll('&lt;[^&gt;]+&gt;',' ');<\/pre>\n\n\n\n<p>Ampersand!  You can&#8217;t have a &amp; or a &amp;amp; in your markup.  Don&#8217;t do it.  Do this instead: <\/p>\n\n\n\n<pre class=\"wp-block-code\" style=\"font-size:12px\"><code>&lt;!&#91;CDATA&#91;&amp;]]&gt;<\/code><\/pre>\n\n\n\n<p><strong><a href=\"https:\/\/issues.salesforce.com\/issue\/a028c00000gAzEmAAK\/bad-request-on-cpq-document-generation-using-salesforce-cpq-for-users-with-mfa-or-2fa-enabled-in-profile\" target=\"_blank\" rel=\"noreferrer noopener\">MFA or 2FA or MFA Enabled in Profile<\/a><\/strong><\/p>\n\n\n\n<p>Check to see if you have &#8220;High Assurance&#8221; set in the Session Settings > Session Security Levels > Multi-Factor Authentication.<\/p>\n\n\n\n<p>What to do? Set that to None and then use a permission set to enable MFA\/2FA. <a href=\"https:\/\/trailhead.salesforce.com\/en\/content\/learn\/modules\/identity_login\/identity_login_2fa\" target=\"_blank\" rel=\"noreferrer noopener\">Here<\/a> is a trailhead!<\/p>\n\n\n\n<p>Thanks to Ashley and <a href=\"https:\/\/www.linkedin.com\/in\/tsenko-aleksiev-salesforce?utm_source=share&amp;utm_campaign=share_via&amp;utm_content=profile&amp;utm_medium=ios_app\" target=\"_blank\" rel=\"noreferrer noopener\">Tsenko<\/a> for their input on this article!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you&#8217;ve ever got this error when generating a document, you probably have less hair than you did before generating the document. There are multiple reasons this could happen: HTML tags in a Quote Line Line Column FieldYou have a standard lines section. You have a list of Line Columns on your Quote Template. One &hellip;<br \/><a href=\"https:\/\/morecpq.com\/index.php\/2019\/03\/06\/generating-a-document-error-generating-document-bad-request\/\" class=\"more-link pen_button pen_element_default pen_icon_arrow_double\">Continue reading <span class=\"screen-reader-text\">Generating a Document: Error generating document: Bad Request<\/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":[4,28,12],"tags":[],"class_list":["post-126","post","type-post","status-publish","format-standard","hentry","category-cpq","category-document-generation","category-error-explanation"],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/posts\/126","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=126"}],"version-history":[{"count":15,"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/posts\/126\/revisions"}],"predecessor-version":[{"id":2768,"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/posts\/126\/revisions\/2768"}],"wp:attachment":[{"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/media?parent=126"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/categories?post=126"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/morecpq.com\/index.php\/wp-json\/wp\/v2\/tags?post=126"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}