If you want to access the keyprefix in Javascript, you will need to use ajax toolkit, for that incude the following in your page: <script src="../../soap/ajax/34.0/connection.js" type="text/javascript"></script>
And in the javascript, you need to use: sforce.connection.sessionId="{!$Api.Session_ID}"; var result=sforce.connection.describeSObjects(["objectAPIName"]); var objectPrefix=result[0].keyPrefix; console.log(objectPrefix);
Hey,
Try using code below and check if it helps:
Refer this link for more help.
<script src="../../soap/ajax/34.0/connection.js" type="text/javascript"></script>
And in the javascript, you need to use:
sforce.connection.sessionId="{!$Api.Session_ID}";
var result=sforce.connection.describeSObjects(["objectAPIName"]);
var objectPrefix=result[0].keyPrefix;
console.log(objectPrefix);