4

I created a LWC which displays a link to an object... and I want that link to "open in a new window" (target "_blank") if the user is viewing it via standard navigation view (non-console). And, if the user is viewing the LWC within Service Console, then it should utilize standard open (NavigationMixin.Navigate) to open in the current window (which will default to opening a new tab within Console).

I can't seem to find a way for the LWC to be aware of it's context - whether or not it is being displayed in Console. Is this possible?

(I can provide the LWC; however, I don't think the details of it are relevant to the question, but if it helps someone answer the question I can.)

1

At the current time, LWC are not supported in the Console. You'd need to put a LWC inside an Aura Component Wrapper in order to use one within the Console. See the LWC Developer Documentation for more on this.

Lightning Web Components doesn’t currently support these Salesforce experiences and tools. To use a Lightning web component with these experiences and tools, wrap the component in an Aura component.

  • Lightning Out
  • Lightning Components for Visualforce
  • Standalone Apps
  • Salesforce Console (Navigation Item API, Workspace API, UtilityBar API)
  • Utility Bars
  • URL Addressable Tabs
  • Flows
  • Snap-ins Chat
  • Lightning for Gmail, Outlook Integration
  • EMP API, Conversation Toolkit API, Omni Toolkit API, Quick Action API
  • Standard Action Overrides, Custom Actions, Global Actions, List View Actions, Related List View Actions
  • Chatter Extensions

To do what you're asking, you'd also need to implement the Lightning Console JavaScript API in your component. If you've not migrated to the Lightning Console, I wouldn't expect the toolkit for the classic console to work with LWC's.

0

So it seems that Lightning Web Components don't have access to some of the objects we could access with the Aura Framework. Lightning Locker blocks them. The current "Migrate Global Value Providers" page doesn't have on its list an item to show what is the current user's Theme.

The @salesforce module does provide a single information now, which is the user's Id. Maybe in future releases Salesforce adds more information, like the theme and other user attributes, like $User global variable in Visualforce pages.


The workaround for now would be to do a server-side call and get the information from the UserInfo class. Use the .getUiThemeDisplayed() method to get the current theme displayed to the user.

The documentation lists some themes, and two of them should be of interest to you:

  • Theme4d—Modern “Lightning Experience” Salesforce theme
  • Theme4u—Lightning Console theme

Theme Theme4d should be the "standard" one, while Theme4u is the console. Store this string in your component and build your navigation methods accordingly.

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.