You need to sign in to do that
Don't have an account?
MOHAMMED BABA
Pick list values are not fetching in the lightning data table of lwc component
Hi Team,
i have lwc data table for the custom object Centre_Res__c now i want to show the pick list values for the field which i created Likelihood_Name_Central__c
import { LightningElement,track,api,wire } from 'lwc';
import { getObjectInfo } from "lightning/uiObjectInfoApi";
import { getPicklistValues } from 'lightning/uiObjectInfoApi';
import Centre_Object from '@salesforce/schema/Centre_Res__c';
const columns = [
{
label: 'Likelihood Ranges Name',
fieldName: 'Likelihood_Name_Central__c', // Update this fieldName based on your data structure
editable: true,
hideDefaultActions: true,
type: 'combobox', // Specify that this column contains a combobox
typeAttributes: {
placeholder: 'Select Likelihood',
options: '$likelihoodPicklistValues', // Bind to your picklist values
value: 'selectedLikelihood' // Bind to the selected value
}
},
]; after export
@api recordId;
@track likelihoodPicklistValues = [];
@track recordTypeId;
@wire(getObjectInfo, { objectApiName: Centre_Object })
likelihoodObjectMetadata({ error, data }) {
if (data) {console.log('data'+JSON.stringify(data));
this.recordTypeId = data; // Set the recordTypeId here based on your use case
console.log(' this.recordTypeId-->'+JSON.stringify( this.recordTypeId));
}
}
// Fetch picklist values with the specific recordTypeId
@wire(getPicklistValues, {
recordTypeId: '$recordTypeId', // Use the custom attribute for recordTypeId
fieldApiName: 'Centre_Res__c.Likelihood_Name_Central__c'
})
wiredPicklistValues({ error, data }) {
if (data) {
this.likelihoodPicklistValues = data.values;
console.log('Picklist Values: ' + JSON.stringify(this.likelihoodPicklistValues));
} else if (error) {
console.error('Error fetching picklist values: ' + JSON.stringify(error));
}
}
HTML:
<template if:true={dataTableValue}>
<div class="myTable">
<lightning-combobox
label="Likelihood Ranges Name"
value={selectedLikelihood}
options={likelihoodPicklistValues}
onchange={handleLikelihoodChange}
></lightning-combobox>
<lightning-datatable data={dataTableValue} columns={columns} key-field="Id" hide-checkbox-column
aria-selected="true" onsave={handleSaveDataTable} draft-values={saveDraftValue}
onrowaction={handleRowAction}>
</lightning-datatable> can you please help with the exact code or if you have any document where i can see the picklist for custom object
i have lwc data table for the custom object Centre_Res__c now i want to show the pick list values for the field which i created Likelihood_Name_Central__c
import { LightningElement,track,api,wire } from 'lwc';
import { getObjectInfo } from "lightning/uiObjectInfoApi";
import { getPicklistValues } from 'lightning/uiObjectInfoApi';
import Centre_Object from '@salesforce/schema/Centre_Res__c';
const columns = [
{
label: 'Likelihood Ranges Name',
fieldName: 'Likelihood_Name_Central__c', // Update this fieldName based on your data structure
editable: true,
hideDefaultActions: true,
type: 'combobox', // Specify that this column contains a combobox
typeAttributes: {
placeholder: 'Select Likelihood',
options: '$likelihoodPicklistValues', // Bind to your picklist values
value: 'selectedLikelihood' // Bind to the selected value
}
},
]; after export
@api recordId;
@track likelihoodPicklistValues = [];
@track recordTypeId;
@wire(getObjectInfo, { objectApiName: Centre_Object })
likelihoodObjectMetadata({ error, data }) {
if (data) {console.log('data'+JSON.stringify(data));
this.recordTypeId = data; // Set the recordTypeId here based on your use case
console.log(' this.recordTypeId-->'+JSON.stringify( this.recordTypeId));
}
}
// Fetch picklist values with the specific recordTypeId
@wire(getPicklistValues, {
recordTypeId: '$recordTypeId', // Use the custom attribute for recordTypeId
fieldApiName: 'Centre_Res__c.Likelihood_Name_Central__c'
})
wiredPicklistValues({ error, data }) {
if (data) {
this.likelihoodPicklistValues = data.values;
console.log('Picklist Values: ' + JSON.stringify(this.likelihoodPicklistValues));
} else if (error) {
console.error('Error fetching picklist values: ' + JSON.stringify(error));
}
}
HTML:
<template if:true={dataTableValue}>
<div class="myTable">
<lightning-combobox
label="Likelihood Ranges Name"
value={selectedLikelihood}
options={likelihoodPicklistValues}
onchange={handleLikelihoodChange}
></lightning-combobox>
<lightning-datatable data={dataTableValue} columns={columns} key-field="Id" hide-checkbox-column
aria-selected="true" onsave={handleSaveDataTable} draft-values={saveDraftValue}
onrowaction={handleRowAction}>
</lightning-datatable> can you please help with the exact code or if you have any document where i can see the picklist for custom object
Please try the below js code
Please mark it as Best Answer if the above information was helpful.
Thanks.
Heads up about the Forums shut down
Important Update
We appreciate your participation in these Salesforce Discussion Forums! It’s active members like you that keep our amazing community going strong.
At this time, we want to give you a heads up that on December 4, 2023, the discussion forums will shut down and all relevant discussions will migrate to the Trailblazer Community digital platform. This move brings all conversations around Salesforce development together in one place and provides more opportunities for our broader community to connect and share. We will be removing outdated, obsolete, or spam content and migrating only relevant discussions to the Trailblazer Community digital platform.
Starting November 20, you can view discussions but not post new questions or responses. On December 2, you will no longer be able to access the discussion forums from the Salesforce Developers website.
Please take these steps before November 30, 2023, 11:59 p.m. PT to ensure your contributions follow you to the Trailblazer Community:
- If you’re not already a member of the Trailblazer Community, sign up for a Trailblazer account using the same login email address associated with your Developer Discussion Forums account. This is crucial.
- If you already have a Trailblazer account, and it’s using a different email address from the one you used for your Developer Discussion Forums account, we recommend that you log in to the Trailblazer Community and connect your forums email address to your Trailblazer account.
Once you’re in the Trailblazer Community, join the Migration Support Hub users group to help you navigate this transition.We will keep you up to date throughout the transition, and we look forward to seeing you joining the developer discussions in the Trailblazer Community!
Sincerely,
The Forums Support Team