checkboxes not defaulting to true as per standard field setup

  • 1
  • Problem
  • Updated 3 years ago
  • Solved
as per title, pic and video

Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
  • sad and confused

Posted 4 years ago

  • 1
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
This is actually due to a Salesforce bug, which has been around for years and is still not fixed.

Please, please, please go to both of the following links and vote for this issue to be fixed!

Idea: Fix field describe getDefaultValue() for checkboxes and picklists
Known issue: DescribeFieldResult.getDefaultValue() returns null for Checkbox field and Picklist field
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
What's the work around?
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Woot! Woot!

10 minutes of google searching and I put this together.

(function(skuid){
	var $ = skuid.$;
	$(function(){
		var checkboxes = $("#reportoptions :input[type=checkbox]");
            
        for(var i=0, n=checkboxes.length;i<n;i++) {
            checkboxes[i].checked = true;
        }
	});
})(skuid);
Photo of Paulo Correia

Paulo Correia

  • 264 Points 250 badge 2x thumb
Hello Pat, I tried to implement this, but it is not working. Could you provide some instructions on how you got it to work. Do we need to set a class or ID. 
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Following up here.  In Spring 16 - Salesforce has indicated that this issue has been fixed.  This should no longer be a problem! 
Having said that, Pat's work around is still super cool!  

https://success.salesforce.com/issues_view?id=a1p300000008XL8AAM
Photo of Rich Slack

Rich Slack

  • 4,134 Points 4k badge 2x thumb
I know Salesforce said the issue is fixed and I hope it is.  I have noticed though that I have a checkbox where the default value is:
"Default Value   Checked"

But when I create a new record, and I am using skuid to skin the new record page, that field shows up and is not checked.  Is there anything we need to do special to get it to recognize the default value on new record creation?

Thank you!
(Edited)
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
When the record is saved, it will get the default value from the SFDC settings, but I think Skuid should show the default value on new records that haven't been saved, too. What say you, Skuid?