1

How can i get Accept button which we see in List views of leads on details page of each lead. I tried but Lead page layout doesn't show option to add this button. Have anyone implemented this function. Is it even possible to put accept from list view on to detail page.

I have seen custom button codes for changing owner. first of all most of these solutions are about accepting cases. Also such custom button will appear on all leads user have access to. We can give error on accepting wrong lead but button shouldn't be visible if lead is not in queue.

Any suggestions?

0

1 Answer 1

3

Accept button is visible only to those Lead ListView where you will choose Filter by Owner as Queue. If the lead is assigned to user then this button will not be visible.

Ques: I tried but Lead page layout doesn't show option to add this button. Have anyone implemented this function. Is it even possible to put accept from list view on to detail page.

And: Salesforce by-default doesn't provide Accept button to be available in Lead Detail page.

In this situation, you need to build custom button with javascript functionality and make it available in the page layout.

Question: We can give error on accepting wrong lead but button shouldn't be visible if lead is not in queue.

There are 2 approaches.

  1. Custom button can be always be visible on the Lead details page and if the lead is not in queue then clicking on this button, show the error message 'Lead is not in Queue.'

  2. If you dont want to display custom button if lead is not in queue, then create separate recordtype and pagelayouts. When owner is getting updated from Queue then write a workflow to update the recordtype. This recordtype should then linked to pagelayout where do not put Accept button.

Javascript Custom button Code where following logic has been incorporated.

a) if user is not part of the queue then he cannot take the ownership.

b) if lead is not in queue then show the error message.

Otherwise, clicking on the button will update user as owner. Put the button on Lead Detail Page Layout.

{!REQUIRESCRIPT("/soap/ajax/31.0/connection.js")} 
var LeadObj = new sforce.SObject("Lead"); 
var previousOwner = "{!Lead.OwnerId}"; 
var currentOwner = "{!$User.Id}"; 
LeadObj.Id = "{!Lead.Id}"; 
LeadObj.OwnerId = "{!$User.Id}"; 

//if previousOwner is queue 
var ownerRec = sforce.connection.query("SELECT owner.type, ownerid, Id from Lead WHERE owner.type= 'Queue' AND OwnerId='"+ previousOwner + "' AND Id='" + LeadObj.Id + "'"); 
var records1 = ownerRec.getArray('records');
if(records1 !=null && records1.length>0)
{ 
  //currentOwner is part of queue
  var currentOwnerRec = sforce.connection.query("SELECT g.UserOrGroupId From GroupMember g WHERE groupId ='" + previousOwner + "' AND g.UserOrGroupId ='" + currentOwner + "'");
  var records2 = currentOwnerRec.getArray('records');

  if(records2 !=null && records2.length>0)
  {
   var result = sforce.connection.update([LeadObj]); 
   location.reload();  
  }
  else
  {
   alert("You cannot take this Lead because you are not part of the queue");
  }
}
else
{
 if(previousOwner == currentOwner) 
 { 
  alert("You are already the Lead Owner "); 
 }
 else
 { 
   var result = sforce.connection.update([LeadObj]);     
   location.reload();
 }
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .