+ Start a Discussion
Neha LundNeha Lund 

How to get the logged in User's profile in Javascript ? pure javasccript no class, no VF page

I am new to Javascript.


Use '{!$Profile.Name}' within quotes wherever u need the profile name in javascript.

Neha LundNeha Lund

No..this did not work...


Can you paste your code please. The following works.




Neha LundNeha Lund

I want to fetch logged inuser's profile Id in home page component, no code as such


Neha LundNeha Lund

I used this in the home page component

alert('Profile: {!$Profile.Id}'); } </script>

 and it display profile {!profile.Id} as it is..


I had pasted that code before i knew dat u r tryng it in a home page component. This works on a vf page actually.

Neha LundNeha Lund

That's why I have mentioned No page.. well do you know whether it can be achieved in Home page component ?



What do u want to do on the basis of the profile Id ? I am not sure if its viable for your requirement but u cn try to assign a vf page to ur component and do all the stuff there.

Neha LundNeha Lund

I just want to fetch the profile Id and if that profileId matches what I want then just bypass else nothing

Seems like a unique requirement.
I don't think you can get Profile Id without any CODE.

There is no way you can access API without the code, you will need either JS or VF page for this.
Yoganand GadekarYoganand Gadekar

If you want to see the logged in uer's profile on aclick of a button say on account just do following;


1. Create a formula field : $Profile.Name (api name of formula field: .profile_name__c)

2. Your java script as below:



            var accountonwerid = '{!Account.profile_name__c}';


Hit kudos and mark this answer if it helps you in any way.



Well creating a formula field and accessing the same wont work via homepage component. Home page component is just a place holder for HTML content and is different from VF pages.

The HTML area doesnt allow anytype of merge fields.
Can you elaborate your requirement lil bit ?
You can do one thing, You can create a VF page and host the same from Homepage component using a HTML iframe. In this will you will get access to MergeFields as well as Controller.