I have a Lightning cmp with some logic, and I need to get Id to continue work with it in Lightning. But I get null. How can I fix it?
public static Id toolId;
@AuraEnabled
public static void createRecord(Tool__c tool){ //I get my tool from Lightning cmp
if(tool != null){
upsert tool Email__c;
toolId = tool.Id;
System.debug(tool.Id + ' ' + toolId); //All is ok here: I can see needed Id
}
}
public static void checkMyId() {
System.debug(toolId); //But here I get null. Why? And how can I get here Id?
}