You need to sign in to do that
Don't have an account?
Arrielle Kooiman
lightning:picklistPath Lightning Component in Community
I'm trying to create a custom lightning:picklistPath component for my community.
I want to use the userId to find the contactId and then find an active service file. My Apex code is working perfectly (I can display the correct service file recordId on my page), but the component still isn't showing up properly. Sometimes it shows up as an empty/grey path, but most times the component doesn't show up at all.
I should have the picklistFieldApiName selected correctly:
In the builder I get this error on page load:
I want to use the userId to find the contactId and then find an active service file. My Apex code is working perfectly (I can display the correct service file recordId on my page), but the component still isn't showing up properly. Sometimes it shows up as an empty/grey path, but most times the component doesn't show up at all.
<aura:component implements="forceCommunity:availableForAllPageTypes,flexipage:availableForAllPageTypes " access="global" controller="PortalController"> <aura:attribute name="serviceFileId" type="String"/> <aura:handler name="init" value="{!this}" action="{!c.doInit}"/> Service File Id: {!v.serviceFileId} <!--This is correct--> <lightning:picklistPath aura:id="picklistPath" recordId="{!v.serviceFileId}" variant="non-linear" picklistFieldApiName="FileStatus__c" > </lightning:picklistPath> </aura:component>
I should have the picklistFieldApiName selected correctly:
In the builder I get this error on page load:
I found out that my code is working as expected. The actual problem is that since I'm not using a RecordPage which has the RecordId immediately on load. I found out that since I'm making that call to the backend, I'm loading the path and then fetching the ID with my previous code.
I needed to make sure the ID was fetched before trying to load the path. To do this, I just added an aura:if to see if the id was null or not.
All Answers
I found out that my code is working as expected. The actual problem is that since I'm not using a RecordPage which has the RecordId immediately on load. I found out that since I'm making that call to the backend, I'm loading the path and then fetching the ID with my previous code.
I needed to make sure the ID was fetched before trying to load the path. To do this, I just added an aura:if to see if the id was null or not.
How your fetching id in controller? Can you please share your controller code? In communities, my component only showing gray path.
Thanks,
SNR
If your component is on a page that has the recordId available you can simply use
implements="force:hasRecordId"
and
<aura:attribute name="recordId" type="String" />
and then use your recordId like {!v.recordId}
Otherwise, if your case is like mine, you'll need to make a callout to apex. I don't have that code any more, but it would look something like:
If you're having any trouble feel free to post your code and I can try to help.
-Arri
If so, I don't think there's any reason for you to make an apex call for the contact record. Instead you’ll only need the component:
Component: In this case, the page already knows what the recordId of the page is, so you can just pass it along to your path.
However, if you’re trying to get the contactId of the currently logged in user and use that to populate this path, you’ll need the following code:
Component: You'll need to run the init method so that we can run the javascript as soon as the page loads.
Controller: We're just calling apex to return the contact Id of the currently logged in user.
Apex: Gets the user and related contact id and passes it back to the controller.
That code should get you the correct path, then you’ll need to work out what you need to do with the handleSelect method.
I hope that helps!
-Arri
If that's not it, try posting a new question.
Good luck!