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
DharshniDharshni 

Home Page Components

Hi,

 

I am developing a side bar, HTML home page component, where I have to query user records.

 

Here is my code :

 

<script scr="../../soap/ajax/26.0/connection.js" type="text/javascript">
</script>
<script>
function showUsers(){ result = sforce.connection.query("Select Name, Id from User limit 1"); records = result.getArray("records"); for (var i=0; i< records.length; i++) { var record = records[i]; console.log(record.Name + " -- " + record.Id); } }
</script> <input type="button" value="Click Me" onclick="showUsers();">

 

I am getting the following error when I click the button.

 

Uncaught {faultcode:'sf:INVALID_SESSION_ID', faultstring:'INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session', detail:{UnexpectedErrorFault:{exceptionCode:'INVALID_SESSION_ID', exceptionMessage:'Invalid Session ID found in SessionHeader: Illegal Session', }, }, }

 

I am trying the above code in a sandbox. To my wonder, the same code works in another development instance.

 

Could anyone explain what is the reason and a fix for this? 

 

Thanks in advance.