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
disturbed118disturbed118 

Getting the ajax toolkit to work in a homepage component

Hi guys i am trying to use the ajax toolkit in a homepage component, the problem is i have to login to get a session is there anyway i can do this without logging in. I have created an html area and added the following code:

 

 

<html>
<head>
	<script src="/soap/ajax/16.0/connection.js" type="text/javascript"></script>
	<script type="text/javascript">
		function ShowUser(){
		    //sforce.connection.login("**************8", "********");
			//sforce.connection.sessionId = '{!$Api.Session_ID}';
		    //var user = sforce.connection.getUserInfo();
			alert(document.cookie);
		}
		window.onload = ShowUser();
	</script>
</head>

<body>
</body>
</html>

 

But if i do not login it won't work?

werewolfwerewolf

You have what you need right there but it's commented out.  Is this not working for you?

 

//sforce.connection.sessionId = '{!$Api.Session_ID}';
lodoss1118lodoss1118

Nope it does not work if i use

 

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

 

it does not work because {!$Api.Session_ID} is null, remember i am doing this in the html area component for home? Can anyone try this out for me thanks

werewolfwerewolf

Perhaps you should try grabbing the sessionId directly from the sid cookie.  That might work...

KaranNangruKaranNangru

Hi

 

Were you able to resolve this problem?  Please share as I am stuck at exactly the same requirement, i.e. I want the session Id in the home page component.

 

Thanks in advance