+ Start a Discussion
sundhar.mks1.3962649227519546E12sundhar.mks1.3962649227519546E12 

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

Hi,
 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="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></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;
              alert(UserRoleName);
        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;
            alert(SiteContract);
            
            if(UserRoleName == 'Development')
            {
            alert('Welcome'+SiteContract);
            SiteContract.style.display = '';
            alert('End'+SiteContract);
                    
            }          

    } 

  });
Hargobind_SinghHargobind_Singh
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 ?