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
sfdcsushilsfdcsushil 

Can we check if user has access to a particular record type in javascript

I am creating a custom clone button. If user is trying to clone a record which has record type for which he does not have access, i want dont want to pass record type id to url.

 

Please let me know how can we check in javascript if user has access to particular record type.

Best Answer chosen by Admin (Salesforce Developers) 
Saikishore Reddy AengareddySaikishore Reddy Aengareddy

{!REQUIRESCRIPT("/soap/ajax/27.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/27.0/apex.js")}


var result = sforce.connection.describeSObject("Contact");

for (var i=0; i<result.recordTypeInfos.length; i++) {
var rt = result.recordTypeInfos[i];
alert("Record Type Name: "+rt.name);
alert("Record Type Id: "+rt.recordTypeId);
alert("Record Type Availability: "+rt.available);
}

All Answers

Saikishore Reddy AengareddySaikishore Reddy Aengareddy

{!REQUIRESCRIPT("/soap/ajax/27.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/27.0/apex.js")}


var result = sforce.connection.describeSObject("Contact");

for (var i=0; i<result.recordTypeInfos.length; i++) {
var rt = result.recordTypeInfos[i];
alert("Record Type Name: "+rt.name);
alert("Record Type Id: "+rt.recordTypeId);
alert("Record Type Availability: "+rt.available);
}

This was selected as the best answer
sfdcsushilsfdcsushil

Thanks for your prompt reply. That worked. 

divya1234divya1234
How can we check if user have access for given record type in apex