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

How to Hide the Lookup field (hyperlink) to particular user??

 How to hide the lookup field hyperlink for particular user only,when they are log in into salesforce. I have create the javascript and added into homepage component but it still not working. Kindly share ur knowledge. here my code

document.write('<script type="text/javascript" src=""></script>');

document.write('<script src="/soap/ajax/28.0/connection.js" type="text/javascript"></script>');

document.write('<script src="/soap/ajax/28.0/apex.js" type="text/javascript"></script>');

Sfdc.onReady(function() {

 if (document.location.href.toString().indexOf("/a0C") != -1 && document.location.href.toString().indexOf("/a0C/o") == -1) {
    var VSCID = window.location.href.substring( window.location.href.indexOf('.com/') + 5);    
    var getProfName = sforce.connection.query("SELECT UserRole.Name,Profile.Name FROM User WHERE Id = '" + window.UserContext.userId + "' ");
    var records = getProfName.getArray("records");
    var SelectedProf = records[0]; 
    var UserRoleName = SelectedProf.UserRole.Name;
        var result = sforce.connection.query("SELECT id,Site_Contract__c FROM Visits__c WHERE Id = '" + VSCID + "'");
            var records = result.getArray("records");
            var SelectedRecord = records[0]; 
            var SiteContract = SelectedRecord.Site_Contract__c;
            if(UserRoleName == 'Development')
   = '';


Not sure why you want to hide it.. if you don't want some specific user to be able to change a field, you can do it via page-layout or security setting. Is that your requirement ?