I have a lightning community where I am trying to update user record when the user clicks the specific button but what happens is when I call that controller from header it updates the records and the community loads up but when I call my controller from inner component It does not update record and community does not loads up at all
Here is the Component
<aura:component implements="forceCommunity:availableForAllPageTypes,force:appHostable,flexipage:availableForAllPageTypes,force:hasRecordId" access="global" controller="POC_TrainingController">
<ltng:require scripts="/resource/jquery"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<div>
<div class="slds-container_large slds-container_center">
<div class="block">
<div class="slds-grid slds-wrap">
<lmsilt:Training />
</div>
</div>
</div>
</div>
</aura:component>
Here is Controller
({
reactivateUser : function(component, event, helper) {
var action = cmp.get("c.reactivateUser");
action.setCallback(this, function(response){
var state = response.getState();
if (state === "SUCCESS")
{
console.log('SUCCESS');
}
else if(state === "ERROR")
{
console.log('ERROR');
}
else {
console.log('There was a problem : '+response.getError());
}
})
$A.enqueueAction(action);
},
showVideo1 : function(cmp, event) {
$("#video1").show();
},
closeModal : function(cmp, event) {
$(".video-modal").each(function( index ) {
$( this ).hide();
});
}
})
Here is my apex class
public with sharing class POC_TrainingController {
@AuraEnabled
public static void reactivateUser()
{
List<GroupMember> gm = [SELECT ID from GroupMember WHERE Group.Name='PC Training DASH Upgrade' AND UserOrGroupId=:UserInfo.getUserId()];
if(UserInfo.getUserId()!=Null && gm.size()>0)
{
List<User> currentUser = [select Id,lmscons__Cornerstone_ID__c,CFS_Activation_Date__c,lmscons__CFS_Status__c from User where Id =: UserInfo.getUserId()];
if(currentUser.size()>0 && currentUser[0].lmscons__Cornerstone_ID__c!=NULL && currentUser[0].lmscons__CFS_Status__c=='Deactivated')
{
currentUser[0].lmscons__CFS_Status__c='Active';
currentUser[0].CFS_Activation_Date__c = datetime.now();
}
update currentUser[0];
}
}
}
<lmsilt:Training />
? If so, please can you paste the code for that component and it's controller? I hope that component also has the apex controller listed.