Add Code Examples to Posts

Add Code Examples to Posts

Last Updated on June 1, 2022 by Rakesh Gupta

Now it is possible to add code samples to posts when the rich text editor is enabled in Chatter Answers and Ideas, and the code will display in the proper format.

Enable Rich Text Editor for Chatter Answers 

To configure it for ideas, follow the below steps in Salesforce Classic: 

  1. Click on Name | Setup | Build | Customize | Chatter Answers |  Chatter Answers Settings
  2. Click Edit
  3. Select Enable Rich Text Editor checkbox
  4. Click Save.

Proof of Concept 

To test this feature, follow the below steps

  1. Navigate to the Idea tab, and click on any idea. It will drill down you to an idea detail page Navigate to Ideas
  2. Here you can paste the sample code ( I will show you the first old output then you will come to know the difference between both).Old way to post code - Step 1public class HelloWorld {
    public static void main(String[] args) {
    System.out.println(“Hello, World”);
    }
    }
  3. Paste the sample code and click on Post.
  4. Now, we will try a new feature first copy a code sample from any text editor and  click on Icon button to open the Add a code sample text box. Similar to the below screenshotNew way to post code By using rich text editor
  5. Click on OK, then click on Post. The code sample appears in the body of the post with its formatting intact.
  6. Below image shows the difference between the old and new method
Old and New way to post code
Old and New ways to postcode

Formative Assessment:

I want to hear from you!

What is one thing you learned from this post? How do you envision applying this new knowledge in the real world? Feel free to share in the comments below.

Have feedback, suggestions for posts, or need more information about Salesforce online training offered by me? Say hello, and leave a message!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.