function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
KJINCANKJINCAN 

Displaying Checkboxes

Does anyone here have any direction on how to get a true/false value to display as a checkmark and x ?  Any help would be great! 

Best Answer chosen by Admin (Salesforce Developers) 
colemabcolemab

If you aren't using a custom VF page and/or components won't work for you, then you may want to consider making a formula field and using it to display your image in a standard Visual Force page.

 

Here is one link and here is another about this

All Answers

colemabcolemab

I would recommend that you create a component that you pass the boolean (true/false) variable into and have that component the reference a static image of a check mark when true and a static image of an x when false.  You can of course use any images you want. 

 

I get this idea from the fact that you can't render input items (like check boxes) in PDF on salesforce.  Here is a thread that talks about this.

KJINCANKJINCAN

Thanks so much!

 

Do you have any idea how to do this?  I am fairly new to this all.

colemabcolemab

First off, you will need to create 2 static resources to hold your images.  For this example, the true/check mark should be anemd "CheckMark" and the false / red x should be named "XMark".  You can get good / free images from here if you need to.

 

Once you have done that you can create this component and name it "boolean2Checkbox":

<apex:component >

	<apex:attribute required="true" type="boolean" name="booleanValue" description="This is the true/false var to be displayed" />

	<apex:image id="TrueImage" value="{!$Resource.CheckMark}" width="50" height="50" rendered="{!booleanValue}" />
	<apex:image id="FalseImage" value="{!$Resource.XMark}" width="50" height="50" rendered="{!NOT(booleanValue)}" />

</apex:component>

PLEASE NOTE: You may need to adjust your height / width to match your image.

 

Here is a sample page using just the component:

<apex:page controller="Test2Controller">

<c:boolean2Checkbox booleanValue="{!MyBooleanVar}" />

</apex:page>

 

And here is a sample controller that sets the var for use on the page by the component:

public with sharing class Test2Controller {

	public boolean MyBooleanVar {get; set;}

	public Test2Controller() {
		MyBooleanVar = true;
	} // end constructor

} // end class

 

 

 

 

colemabcolemab

If you aren't using a custom VF page and/or components won't work for you, then you may want to consider making a formula field and using it to display your image in a standard Visual Force page.

 

Here is one link and here is another about this

This was selected as the best answer