I have a problem when I try to send the recordId to my Apex Controller, in this case the Apex don't receive the parameter, so I can't use it into the apex controller.
The Lightning Component is in a Community.
Can you help me? Thanks.
Component
<aura:component controller="MyController" implements="force:appHostable,flexipage:availableForAllPageTypes,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
<aura:handler name="init" action="{!c.doInit}" value="{!this}" access="global" />
<aura:attribute name="artId" type="String" default="{!v.recordId}" access="global" />
</aura:component>
Design
<design:attribute name="artId" label="Record ID" default="{!recordId}" />
Controller JS
doInit : function(component, event, helper) {
var action = component.get("c.setViewStat");
var artId = component.get("v.recordId");
console.log(artId);
action.setParams({
"artId":artId
});
}
Apex Controller
global with sharing class MyController{
@AuraEnabled
global static void setViewStat(String artId) {
try{
Code...
}
catch(Exception e){
System.debug(e);
}
}