+ Start a Discussion
Apex Code DevelopmentApex Code Development 

How to retrieve userRoleId using Ajax in javascript?

Hii Folks!!!!

 

I'm working on Professional Edition.I need to retrieve userRoleId of the user who logs in to the system.

I'm getting username,userId,profileId and sessionId correctly through the following code:

var user = sforce.connection.getUserInfo();

alert(user.userName);

alert(user.Id);

alert(user.profileId);

alert(user.sessionId);

 

But could not retrieve "userRoleId".Can anyone suggest me with a solution.

 

Thanks & Regards,

Jagadeesh K.

Best Answer chosen by Admin (Salesforce Developers) 
Pradeep_NavatarPradeep_Navatar

Tryout the sample code given below :

 

            <apex:page >

            <script src="/soap/ajax/19.0/connection.js" type="text/javascript"></script>

            <script src="/js/functions.js"></script>

            <script src="/soap/ajax/19.0/apex.js" type="text/javascript"></script>

 

                                                <script>

                                                                function GETINFO()

                                                                {

                                                                sforce.connection.sessionId="{!$Api.Session_ID}";

                                                                var user = sforce.connection.getUserInfo();

                                                                alert(user.userName);

                                                                alert(user.roleId);

                                                                alert(user.userId);

                                                                alert(user.profileId);

                                                                }

                                                </script>

                                                <script>

                                                {

                                                  window.onload=GETINFO();

                                                }

                                                </script>

                </apex:page>

 

Hope this helps.

All Answers

Pradeep_NavatarPradeep_Navatar

Tryout the sample code given below :

 

            <apex:page >

            <script src="/soap/ajax/19.0/connection.js" type="text/javascript"></script>

            <script src="/js/functions.js"></script>

            <script src="/soap/ajax/19.0/apex.js" type="text/javascript"></script>

 

                                                <script>

                                                                function GETINFO()

                                                                {

                                                                sforce.connection.sessionId="{!$Api.Session_ID}";

                                                                var user = sforce.connection.getUserInfo();

                                                                alert(user.userName);

                                                                alert(user.roleId);

                                                                alert(user.userId);

                                                                alert(user.profileId);

                                                                }

                                                </script>

                                                <script>

                                                {

                                                  window.onload=GETINFO();

                                                }

                                                </script>

                </apex:page>

 

Hope this helps.

This was selected as the best answer
Apex Code DevelopmentApex Code Development

Yes....It worked

 

Thanks a lot Pradeep for your quick solution.

 

Regards,

Jagadeesh K.