function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sam SwannSam Swann 

Redirecting to URL based on selected menu item?

Hi

I am using: lightning:buttonMenu for the user menu in my portal.
I am not sure how to set params to have the appropriate URLs to.
 User-added image

User-added image
User-added image

Any suggestions are welcome.
Sam SwannSam Swann
Is the community is ALIVE?
Can someone please repond to my question?

Thanks.
sfdcMonkey.comsfdcMonkey.com
hi Sam Swann,
what value have store in your selectedMenuItemValue variable ?
If it store tab name like [home , My Profile or Logout] then you can add a conditional statement for redirect to URL 
for example :
 
var selectedMenuItemValue  = event.getparam("value");    //


 if(selectedMenuItemValue == 'Home'){
     var urlEvent = $A.get("e.force:navigateToURL");
     urlEvent.setParams({
       "url": 'https://xyz.com/Home'
     });
     urlEvent.fire();
	
 }
 else if(selectedMenuItemValue == 'My Profile'){
     var urlEvent = $A.get("e.force:navigateToURL");
     urlEvent.setParams({
       "url": 'https://xyz.com/MyProfile'
     });
     urlEvent.fire();
 }
 else if(selectedMenuItemValue == 'Logout'){
      var urlEvent = $A.get("e.force:navigateToURL");
     urlEvent.setParams({
       "url": 'https://xyz.com/LogOut'
     });
     urlEvent.fire();
 }
Hopes it helps you
thanks let me know if it helps you
Thanks sfdcmonkey.com



 
Sam SwannSam Swann
Hi piyush_soni

That's really helpful. Thanks.
With respect to Profile page, I need to access the current login user id. Anyways I am using a Init method in the controller to get the current logged in user. But, how can I concatinate the user id to the URL? 
 
if(selectedMenuItemValue == 'Profile'){
          	 var urlEvent = $A.get("e.force:navigateToURL");
             urlEvent.setParams({
                 "url": '/profile/' + component.get("v.user.Id");
             });
             urlEvent.fire();
}
I thought this would do it, but that's not working. Could you please help me with this?

Thanks,
Sam
sfdcMonkey.comsfdcMonkey.com
hi Sam
so what is exact URL to redirect profile page on community ?
 
Sam SwannSam Swann
So on our community, in the page settings, the URL for profile looks like:
/profile/:recordId

The recordId should be userId. So I am trying to get the Id concatenated at the end of the redirecting URL.

Let me know if you have any further questions.
Thanks
sfdcMonkey.comsfdcMonkey.com
then it's must be redirect to your community profile page so what happen with this URL
"url": '/profile/' + component.get("v.user.Id");
?
sfdcMonkey.comsfdcMonkey.com
Hey ,
 DON'T use ' ; ' semi comma after "url": '/profile/' + component.get("v.user.Id");

use below code once
if(selectedMenuItemValue == 'Profile'){
          	 var urlEvent = $A.get("e.force:navigateToURL");
                urlEvent.setParams({
                 "url": '/profile/' + component.get("v.user.Id")
             });
             urlEvent.fire();
}
now it's works
let me know if it helps
thanks
 
Sam SwannSam Swann
Hey piyush_soni

I have fixed the issue by trail-and-error and it worked with this below piece:
"url": '/profile/' + component.get("v.user").Id
I appreciate your time.

Thanks

 
Neeru-LS NagpalNeeru-LS Nagpal
Hi piyush_soni,

I also want to implement something like this but i want to add condition for record type.
goToURL: function(component, event, helper) {
        var objTicket = component.get("v.ticketRecord");
        if((objTicket.Record_Type_Name__c == 'Relativity Support') && (objTicket.Escalated_to_kIE__c == true)){
            var urlEvent = $A.get("e.force:navigateToURL");
            urlEvent.setParams({
            	"url" : 'mailto:'+objTicket.ContactEmail+'?cc='+'support@relativity.com;'+objTicket.Account.Support_CC_Emails__c+';'+objTicket.Owner.Email+'&subject=Relativity Ticket:'+objTicket.CaseNumber':'+objCase.Subject
        	});
            urlEvent.fire();
        }
    }

I have written condition like this. but this is not working, error is coming as unexpected String. Could you please help me here to resolve the issue.

Thanks
Neeru
pushpesh bisht 16pushpesh bisht 16
Hello All,

I have following code written for lightning component

here is my condition the condition works fine but it gives me response as Visit Baidu! link
iam stucked here i want to redirect this to particular URL rather than giving me link, Is their anyway so that i can skip this link and it will redirect to the URL directly without giving me link 

<aura:if isTrue="{!con.BillingCountry =='China'}">
          <a href="https://map.baidu.com"> Visit baidu!</a>   
        </aura:if>

Please help here iam stuck in this.

Thanks
Pushpesh