You need to sign in to do that
Don't have an account?
Gonzalo Quevedo 15
DynamicPickList Class getDefaultValue() method not working
Hi!,
I'm populating a configuration picklist using DynamicPickList class in lightning component app builder page, but it seems that getDefaultValue() method is not working. I even copied/pasted Salesforce example and it didn`t work either! :(
This is salesforce example: (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_class_VisualEditor_DynamicPickList.htm#apex_class_VisualEditor_DynamicPickList)
And this is the picklist output in lightning app builder:
Anyone is having the same issue? Is something that I missed here?
Thanks!
I'm populating a configuration picklist using DynamicPickList class in lightning component app builder page, but it seems that getDefaultValue() method is not working. I even copied/pasted Salesforce example and it didn`t work either! :(
This is salesforce example: (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_class_VisualEditor_DynamicPickList.htm#apex_class_VisualEditor_DynamicPickList)
global class MyCustomPickList extends VisualEditor.DynamicPickList{ global override VisualEditor.DataRow getDefaultValue(){ VisualEditor.DataRow defaultValue = new VisualEditor.DataRow('red', 'RED'); return defaultValue; } global override VisualEditor.DynamicPickListRows getValues() { VisualEditor.DataRow value1 = new VisualEditor.DataRow('red', 'RED'); VisualEditor.DataRow value2 = new VisualEditor.DataRow('yellow', 'YELLOW'); VisualEditor.DynamicPickListRows myValues = new VisualEditor.DynamicPickListRows(); myValues.addRow(value1); myValues.addRow(value2); return myValues; } }
And this is the picklist output in lightning app builder:
Anyone is having the same issue? Is something that I missed here?
Thanks!
The best article about the dynamic picklist (complete use, better than the Salesforce documentation):
https://agarciaodeian.com/2017/08/08/picklist-dinamicos-en-lightning-components/
The VisualEditor.DataRow seems just useful for selecting the default values.
I'm glad you reported this issue as we are experiencing the exact same behavior you are. Within the Lightning App Builder, after initially dragging-and-dropping our Lightning component onto the page, the initial default value of our drop down is an empty value:
Here is my code:
Lightning design file:
Apex class:
Suspected Salesforfce Bug:
The Salesforce provided Apex method fails to invoke (my system.debug() statement fails to execute):
Please post back if you discover a solution!