Conditionally display Path on LWC based on record type from apex class

259 views Asked by At

As a new developer, I'm struggling with something that is probably simple for many of you. Thus, I'm hoping to get some assistance.

I have wired an apex class SOQL query to an LWC. I am able to display this data in my LWC without a problem. On the LWC, I have a path which displays values as expected. However, I only want to display the path when the record type of the object is a certain value.

HTML

<template lwc:if={recordTypeCFY}>                
    <lightning-progress-indicator current-step={mmp.MMP_Status__c} type="path" variant="base">
           <template for:each={steps} for:item="step">
                 <lightning-progress-step label={step.label} value={step.value} key={step.label}>      
                 </lightning-progress-step>
           </template>
    </lightning-progress-indicator>                 
</template>here

I understand how to use the lwc:if conditional rendering functionality, and I know you can't use an expression. I've successfully used a property to does this with another component.

Apex class

  public with sharing class MovesManagementPlanController {

            @AuraEnabled(cacheable = true)
            public static List <Moves_Management_Plan__c> mmpCFY(Id accountId){
            return  
                [SELECT Id, Name, MMP_Status__c, RecordType.DeveloperName
                FROM   Moves_Management_Plan__c
                WHERE  Account__c = :accountId];
            }
  }

Javascript File

 import mmpCFY from '@salesforce/apex/MovesManagementPlanController.mmpCFY';
        
        @wire(mmpCFY, {accountId : '$recordId'}) 
        mmpData;

        recordTypeCFY = false;

         if (?????? === 'CFY') {  //CFY is a record type
           this.recordTypeCFY = true;
           }
         }

I don't know how get the RecordType.DeveloperName value to populate a property in the Javascript so I can use it in an if/then statement to set the the recordTypeCFY value to true to conditionally display the path.

Please note that I had to use a SOQL query to get the data because I'm displaying an iteration of a child object on the Account page. Could someone assist me in this matter? I truly appreciate it.

0

There are 0 answers