Wednesday, 17 October 2012

Quick way of accessing Grant Login Access

Whenever a end user faces any issue with a record in the system, System Administrator is expected to analyse if the issue is common to all the users or only to specific users(due to lack of permissions, profile/role settings, record level rights etc.,).
Granting Login Access is to assist System Administrator(s) to view Salesforce as that of the End User in order to have a deep dive into the issue.


This is crtical because, System Administrator need check the issue with the same kind of Permissions and Profile settings as that of the User to have a detailed approach of how and when the issue exists instead of trying with higher level of permissions as a System Admin.

This post is a mere approach to demonstrate that we can use login access just by a click without navigating to User Detail page and clicking "Login" button.
This post shows a quick way to login as Opportunity Owner from the Opportunity record itself, assuming that Opportunity Owner is facing some issues and granted login access to the System Administrator.

Create the Custom Link as below,

Your Name ➤ Setup ➤ Customize ➤ Opportunities ➤ Buttons and Links ➤ New

Label : Login as Opportunity Owner
Name  : Login_as_Opportunity_Owner
Display Type : Detail Page Link
Behavior : Execute Javascript
Content Type : onClick Javascript

Paste the following code and add the link in the Opportunity Page Layout,

{!REQUIRESCRIPT("/soap/ajax/18.0/connection.js")}
sforce.connection.query("SELECT Id,Name,StageName,OwnerId FROM Opportunity where Id= '{!Opportunity.Id}'",{onSuccess: handleSuccess,onFailure: handleFailure});
function handleSuccess(queryresult)
{
    try
    {
        records = queryresult.getArray("records");    
        var loggedUser = '{!$User.Id}';
        var user = sforce.connection.getUserInfo();
        if(loggedUser!=records[0].OwnerId.substring(0,15))   
        {
            window.location.href = '/servlet/servlet.su?oid='+user.organizationId+'&suorgadminid='+records[0].OwnerId.substring(0,15)+'&targetURL=%2F'+'{!Opportunity.Id}';
        }   
        else
        {
            alert("You are the Opportunity Owner");
        }
    }
    catch(error)
    {
        alert(error);
    }
}
function handleFailure(error)
{
    alert(error);
}

This will work only if the Opportunity Owner has granted login access to the Sys Administrator, otherwise shows "Insufficient access error".



Here is the new Custom Link called "Login as Opportunity Owner" in the Opportunity Page, when on clicking gets logged in as the Opportunity Owne
Summer '12 Realease Addition to Grant Login Access :
To allow administrators to log in as any user in the organization without asking end-users to grant login access to them,
This option will be available to your organization by salesforce upon request.
Once enabled, use the below path Administrators Can Log in as Any User using the below path,

Your Name ➤ Setup ➤ Security Controls ➤ Login Access Policies

No comments:

Post a Comment