Creating Dynamic Progress Indicator Using lWC.
HTML File
JS File
import { LightningElement, wire, track, api } from 'lwc';
import JobApplicationStatusValues from '@salesforce/apex/CommonMethods.getPicklistValues';
import { getRecord, getFieldValue, } from "lightning/uiRecordApi";
import STATUS_FIELD from "@salesforce/schema/Candidate__c.Job_Application_Status__c";
export default class DynamicProgressIndicator extends LightningElement {
@track statusValues = [];
@track currentStatus;
@api recordId;
@wire(JobApplicationStatusValues) addFieldsToPath({ error, data }) {
let tempStatus = [];
if (data) {
let i = 0;
for (let key in data) {
tempStatus.push({
value: data[key],
key: key,
className: 'slds-path__item slds-is-incomplete',
});
i++;
}
this.statusValues = JSON.parse(JSON.stringify(tempStatus));
} else {
console.log('error in getting values',error)
}
}
@wire(getRecord, { recordId: "$recordId", fields:[STATUS_FIELD] } )
caseRecord({ error, data }) {
if (data) {
this.currentStatus = getFieldValue(data, STATUS_FIELD);
} else {
console.log('error in getting values',error)
}
}
connectedCallback() {
this.recordId = this.recordId;
}
}
XML File
61.0
true
lightning__RecordPage
In this video we have demonstrated and explain the code.