3

force:hasRecordId interface doesn't get recordId attribute value of the record in lightning component in Winter 18?

code: comp code:

<aura:component implements="force:lightningQuickAction,force:hasRecordId" >

   <aura:attribute name="recordId" type="id" access="global"/> 
  <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
</aura:component>

comp controller js:

({
 doInit: function(component)
 {
 console.log("recordidjs: "+component.get("v.recordId"));
 }
})

Result:

We have added the above component in record detail page In Winter 18 - we get "recordidjs: undefined" in console

This same code displays record id in previose releases

  • Remove the aura:attribute from your component and try again. – sfdcfox Sep 17 '17 at 23:21
  • Just tried in one of the winter orgs and this works for me without any issues ?Which object are you getting this error on ? – Mohith Shrivastava Sep 17 '17 at 23:26
  • Also it did not even compile and i had to add flexipage:availableForRecordHome interface and then change parameter to "component" instead of cmp – Mohith Shrivastava Sep 17 '17 at 23:29
  • @Ramakrishnan Ayyanar, you should change function(cmp) to function(component) for starters. – glls Sep 17 '17 at 23:32
  • We have used component in original. it is typo mistake while pasting the code here. The issue that we face is the recordId is not fetched when the component is added as a Quick action but the same works when the component is added as a tab (by implementing flexipage:availableForAllPageTypes) – – Ramakrishnan Ayyanar Sep 18 '17 at 11:12
2

I had the same problem and what worked for me was:

1) Remove the aura attribute recordId

2) My lightning component was being called from a global action, this was working before Winter 18, but now I had to create a custom action in my object - Checking the documentation the reocrdId is not being set when "Invoking the component from a global action (even when you’re on a record page)"

Thanks

  • Moving the button to be an object action instead of a global action did the trick for me. Thank you so much! – joshuadelange Oct 10 '17 at 9:42
  • Worked for me as well. Still would like to see the global action BUG fixed – Eric Nov 6 '17 at 2:27
0

You are using component.get("v.recordId")

As per your code , change component to cmp.

  • We have used component in original. it is typo mistake while pasting the code here. The issue that we face is the recordId is not fetched when the component is added as a Quick action but the same works when the component is added as a tab (by implementing flexipage:availableForAllPageTypes) – – Ramakrishnan Ayyanar Sep 18 '17 at 11:12
0

As per the documentation you do not need to re-define the recordId attribute.

Remove it from your component markup and it will work.

-2

we are also having same issue as mentined by Ramakrishnan .Any update on this

@@@@@@@@@@@
We have used component in original. it is typo mistake while pasting the code here. The issue that we face is the recordId is not fetched when the component is added as a Quick action but the same works when the component is added as a tab (by implementing flexipage:availableForAllPageTypes) – @@@@@@@@@@@@@@

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.