Answers.Body: <p>I confirmed that this is caused by having a name badge layout with a spacer field and sorting the participants by name prior to generating name badges.  My work-around for now is to instead of using a spacer in the badge layout, to insert an unused blank field, and I can now print alphabetically sorted badges.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-25T16:28:20.350Z
Answers.LastActivityDate: 2019-02-25T16:28:20.350Z
Answers.UserDisplayName: Larry K.
Body: <p>We need to print event badges in alphabetical order instead of the date registered order that you initially get from a participant search.  The PDF creation completes successfully with the default sort, but after changing to alphabetical order, you get a yellow screen DB Error: unknown error.  Is there a way around this?  Thanks!</p>
  
  <p>We are on CiviCRM 5.4.0 on Drupal 7.63</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-02-20T21:12:03.177Z
Comments.Text: Could you please edit your question to say what version of CiviCRM you're using? Thanks!
Comments.UserDisplayName: Jon G - Megaphone Tech
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-02-20T22:01:46.710Z
Comments.Text: Thanks Larry! One more thing to help folks help you: Go to **Administer menu » System Settings » Debugging and Error Handling**.  Turn on both "debug mode" and "backtrace", then repeat the steps that caused the error.  The error will become much more detailed.  Edit your question to include the extra details (as text, not a screenshot please!).  The extra detail will help us know what's going on!
Comments.UserDisplayName: Jon G - Megaphone Tech
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-02-21T17:15:51.057Z
Comments.Text: Just tried on dmaster.demo.civicrm.org
  
  Find participants- event name=????
  
  From results- click on participants heading to order by participant name
  Select all
  Print name badge
  
  Badges print in search result order.
  
  Just double-checking Is that your process? 
  
  Issue may be fixed in upgrade, or the debug/backtrace may point to another issue in your set up.
Comments.UserDisplayName: Craig Almond
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-02-22T02:03:35.320Z
Comments.Text: Yes, Craig Almond, that's what I was doing.
Comments.UserDisplayName: Larry K.
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-02-22T02:13:57.330Z
Comments.Text: #4..(575): DB_Error->__construct(-1, 16, (Array:2), "SELECT contact_a.id as contact_id, contact_a.image_URL as `image_URL`, contac...")
  #5..[internal function](): PEAR->_raiseError(Object(DB_mysqli), NULL, -1, NULL, NULL, "SELECT contact_a.id as contact_id, contact_a.image_URL as `image_URL`, contac...", "DB_Error", TRUE)
  #8..1907): PEAR->raiseError(NULL, -1, NULL, NULL, "SELECT contact_a.id as contact_id, contact_a.image_URL as `image_URL`, contac...", "DB_Error", TRUE)
  #9..(933): DB_common->raiseError(-1, NULL, NULL, NULL, "1052 ** Column 'sort_name' in order clause is ambiguous")
Comments.UserDisplayName: Larry K.
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-02-22T02:17:29.193Z
Comments.Text: Excerpt above from backtrace which was much too long for the post character limit.  This part seemed to be the most pertinent.
Comments.UserDisplayName: Larry K.
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-02-25T16:04:20.620Z
Comments.Text: According to this issue submitted at https://lab.civicrm.org/dev/core/issues/729 If you have a name badge layout with a spacer field and you sort the participants by name prior to generating name badges, the following error occurs.
  Column 'sort_name' in order clause is ambiguous 1052
Comments.UserDisplayName: Larry K.
Tags: <search-results><pdf><participants><printing>
Title: Error printing event badges after sorting by participant name
ThreadText: # Error printing event badges after sorting by participant name
  
  (Asked by: username_0 on 2019-02-20)
  
  We need to print event badges in alphabetical order instead of the date registered order that you initially get from a participant search. The PDF creation completes successfully with the default sort, but after changing to alphabetical order, you get a yellow screen DB Error: unknown error. Is there a way around this? Thanks!
  
  We are on CiviCRM 5.4.0 on Drupal 7.63
  
  **Tags:** search-results, pdf, participants, printing
  
  > **Comments:**
  > **username_1**: Could you please edit your question to say what version of CiviCRM you're using? Thanks!  
  > **username_1**: Thanks Larry! One more thing to help folks help you: Go to **Administer menu » System Settings » Debugging and Error Handling**.  Turn on both "debug mode" and "backtrace", then repeat the steps that caused the error.  The error will become much more detailed.  Edit your question to include the extra details (as text, not a screenshot please!).  The extra detail will help us know what's going on!  
  > **username_2**: Just tried on dmaster.demo.civicrm.org  Find participants- event name=????  From results- click on participants heading to order by participant name Select all Print name badge  Badges print in search result order.  Just double-checking Is that your process?   Issue may be fixed in upgrade, or the debug/backtrace may point to another issue in your set up.  
  > **username_0**: Yes, username_2, that's what I was doing.  
  > **username_0**: #4..(575): DB_Error->__construct(-1, 16, (Array:2), "SELECT contact_a.id as contact_id, contact_a.image_URL as `image_URL`, contac...") #5..[internal function](): PEAR->_raiseError(Object(DB_mysqli), NULL, -1, NULL, NULL, "SELECT contact_a.id as contact_id, contact_a.image_URL as `image_URL`, contac...", "DB_Error", TRUE) #8..1907): PEAR->raiseError(NULL, -1, NULL, NULL, "SELECT contact_a.id as contact_id, contact_a.image_URL as `image_URL`, contac...", "DB_Error", TRUE) #9..(933): DB_common->raiseError(-1, NULL, NULL, NULL, "1052 ** Column 'sort_name' in order clause is ambiguous")  
  > **username_0**: Excerpt above from backtrace which was much too long for the post character limit.  This part seemed to be the most pertinent.  
  > **username_0**: According to this issue submitted at https://lab.civicrm.org/dev/core/issues/729 If you have a name badge layout with a spacer field and you sort the participants by name prior to generating name badges, the following error occurs. Column 'sort_name' in order clause is ambiguous 1052  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2019-02-25. Score: 2
  
  I confirmed that this is caused by having a name badge layout with a spacer field and sorting the participants by name prior to generating name badges. My work-around for now is to instead of using a spacer in the badge layout, to insert an unused blank field, and I can now print alphabetically sorted badges.
  
  
  ---
  
  