You need to sign in to do that
Don't have an account?
Anuj kumar rai
Can a wired property that is getting a list of strings from apex method be treated as an array directly?
This is my apex method that is returning a list:
@AuraEnabled(cacheable=true)
public static List<String> getTypePicklistValuesMethod(){
List<String> pickListValuesList= new List<String>();
Schema.DescribeFieldResult fieldResult = Task.Type.getDescribe();
List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
for( Schema.PicklistEntry pickListVal : ple){
pickListValuesList.add(pickListVal.getLabel());
}
return pickListValuesList;
}
and this is my JS file:
import { LightningElement, wire} from 'lwc';
import picklistValues from '@salesforce/apex/TaskCreator.getTypePicklistValuesMethod';
export default class ListToMapPractice extends LightningElement
{
@wire(picklistValues)
typeValues;
}
So can this "typeValues" be directly used as an array or is there something more to it that i don't know yet.
@AuraEnabled(cacheable=true)
public static List<String> getTypePicklistValuesMethod(){
List<String> pickListValuesList= new List<String>();
Schema.DescribeFieldResult fieldResult = Task.Type.getDescribe();
List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
for( Schema.PicklistEntry pickListVal : ple){
pickListValuesList.add(pickListVal.getLabel());
}
return pickListValuesList;
}
and this is my JS file:
import { LightningElement, wire} from 'lwc';
import picklistValues from '@salesforce/apex/TaskCreator.getTypePicklistValuesMethod';
export default class ListToMapPractice extends LightningElement
{
@wire(picklistValues)
typeValues;
}
So can this "typeValues" be directly used as an array or is there something more to it that i don't know yet.
Yes, you can use the wire property directly on the HTML. but as I can see that you are quering the picklist values and wanted to show on the HTML.
If yes, please use the below code- Please let me know if this helps!
Thanks,
Shivdeep Kumar