1

I working on 'Build Flexible Apps with Visualforce Pages and Lightning Components' trailhead module and I was on 'Create a SimilarProperties Lightning Component' there is one statement comes up which states " the component also uses the force:hasRecordIdinterface, which will automatically retrieve the Id of the current Record page and store it in the with a name of recordId."

enter image description here

My question is is it mandatory to declare attribute with name recordId instead on any other name like oppId etc. and what if I have multiple attribute declare with same type="Id", how framework works in this case.

many of you might feel this question stupid but it just came to my mind. I am gonna try it myself but want to know your expert views.

link to trailhead : https://trailhead.salesforce.com/projects/workshop-lightning-programmatic/steps/programmatic-step-5

Thanks in advance.

1 Answer 1

4

When you implement the interface force:hasRecordId, the platform expects you to have an attribute with the name recordId, and not anything else. Imagine this is like interfaces in Apex, but with the disadvantage that the compiler cannot stop you from not completely implementing the interface you desire.

While you can certainly have many attributes of type ID, the platform will only prepopulate the one named recordId with the ID of the record you are in.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .