Home > Back-end >  Finding or creating the url for a new Lightning Web Component/ Sales Force
Finding or creating the url for a new Lightning Web Component/ Sales Force

Time:03-18

I am new to Sales Force and I want a newly created Lightning Web Component to be accessible by url to outside clients. I'm adding to an existing SalesForce instance.

We have several existing lwc in our code base, two of which are accessible by url to outside clients. The both follow a similar pattern:

[organization url] /schedule/s/self? [query params]  (name of lwc "selfSchedule")
[organization url] /schedule/s/opt-out? [query params] (name of lwc "subscriptionOptOut")

I want to do something similar with the new component, but I don't understand where the middle values are coming from or where they are defined. I'm not sure why it's "schedule" nor have I been able to reason where "self" and "opt-out" come from. Will the center value always be s?

I have looked in the GUI as well as the files in the code base for a place where these values are defined to no avail.

Can someone please offer guidance in where to find/define the middle URL values so that I can properly reference them?

CodePudding user response:

Your organisation is using a "Site" or "Experience Cloud" (formerly known as Customer / Partner Community, formerly known as Customer / Partner Portal). Go to Setup -> Sites or Setup -> Experience... and have a look.

If you had no idea you're using a community there's a chance you don't have real community users & licences (cheaper than regular licenses but still), you might have just the "guest user" for unauthenticated access. Be careful what you expose to guest users

There might be some trailheads and videos if you're lost.

  1. Go to community builder and create new page for your component (but don't add the component yet, maybe add just some plain text). The page editor is similar but not identical to "Lightning App Builder" editor. This is the part where you choose "self", "opt-out" etc.
  2. Maybe add your page to Navigation Menu at top of the page.
  3. Hit "Publish" and check if you can see the new page.
  4. Compare your component's "meta.xml" file with the other two. You'll need to add a target (probably lightningCommunity__Page) to it to indicate it's OK to drop it on community page. Deploy.
  5. If your component uses Apex - you need to grant permission to run this class to the guest user (or normal community users, if it turns out you actually have them). Guest user is still a Profile, you have all the normal checkboxes - but it's bit hidden. Steps depend whether you have a Site or community.
  6. You're ready to go back to your page, drop your component on it and hit Publish again.
  7. If you think there are apex errors - debugging guest users is bit of a pain too. Go to Setup -> Debug logs and search users with "guest" in name. Something like "{your community name} Site Guest User" should pop up.
  • Related