0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Does a Lightning Component know if it is in a Community or a standard Lightning Salesforce page?

Posted at

#Lightning コンポーネントでコミュニティーか通常の組織環かどうかを見分ける方法

Lightning component .cmp


Apex controller .cls
public with sharing class CustomController {
@AuraEnabled
public static boolean isCommunity(){
Id siteId = Site.getSiteId(); // take a look at the apex class Site, you may find more useful method concerning site/community
if (siteId != null) {
return true;
}
return false;
}
}

Lightning component controller .js
({
init : function(component, event, helper) {
var action = component.get("c.isCommunity");
action.setCallback(this, function(response) {
var isCommunity = response.getReturnValue(); // do any operation needed here
});
$A.enqueueAction(action);
}
})

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?