0

I got a requirement like want to hide leads in my org based on the lead status.i have a value in status field called customer.so,when user selects customer in status field the lead had to be hidden irrespective of the owner and access to edit only system admin.I had created a validation rule for this requirement.for reference

AND(ISPICKVAL(Status,'Customer'), $Profile.Name <> "System Administrator")

But it is not useful in my purpose because the user doesn't even save the lead with status field value with customer because the validation rule fires before saving the record.

I don't have any idea is it possible to hide a lead in sfdc org. Can anyone help me guys.

1
  • 1
    Isn't a Lead automatically hidden when it is converted? Validation rules have to do with data cleanliness not data visibility.
    – pchittum
    Commented Mar 7, 2016 at 21:55

1 Answer 1

3

Leads are normally "hidden" when converted, but if you wanted to do this purely through sharing, here's how you might go about it.

Org-Wide Defaults: Private

To hide anything, you first have to hide everything, then show things. So, in the first step, you'll need to make all leads private. This is found in Setup > Security Controls > Sharing Settings.

Public Groups

To share leads with most everyone, you may want to set up a public group. This is found in Setup > Manage Users > Public Groups. If the goal is still to generally allow everyone access to all leads that are not to be hidden, you can use the default group Entire Organization.

Criteria-Based Sharing

To share leads that do not meet the Customer Status, go back to Sharing Settings, and create a new Criteria-Based Lead Sharing Rule. The rule should be the inverse of what you're trying to hide, so it should look like this:

Lead Status not equal to Customer

System Administrators already have automatic, unlimited access to all leads, so there's no need to include that as a criteria.

Lead Ownership

Finally, leads are always visible to the owner of the lead, so the final step is to assign ownership of the lead to a System Administrator when the status reaches Customer. To do this, you might use a trigger, flow, or workflow rule. As a trigger, it might look like this:

trigger changeToSysAdmin on Lead (before insert, before update) {
    Lead[] newCustomers = new Lead[0];
    for(Lead record: Trigger.new) {
        if(record.Status == 'Customer') {
            newCustomers.add(record);
        }
    }
    if(!newCustomers.isEmpty()) {
        User someAdmin = [SELECT Id FROM User WHERE Profile.Name='System Administrator' AND IsActive = TRUE LIMIT 1];
        for(Lead record: newCustomers) {
            record.OwnerId = someAdmin.Id;
        }
    }
}

You could also build this as a Flow, and then attach a Process Builder action to the flow to assign ownership.

8
  • I'm not sure OP says anything about converted leads, that said, the OWD Private is the starting point of everything to solve this as you have outlined; in final step, leads could also be assigned to a queue whose members were defined by some public group (such as sysads) - this avoids having these leads assigned to different sysads over time as sysads come and go.
    – cropredy
    Commented Mar 8, 2016 at 0:57
  • I'm try to do it.Let me know thanks for sharing knowledge @sfdcfox
    – Pavan tej
    Commented Mar 8, 2016 at 18:52
  • Hi @sfdcfox in my org in sharing rules lead is private.And there is a team called LVS.This team is try to contacts every leads and generate opportunity if lead will qualify and sometimes they get duplicates so my requirement is to whenever this team put account status as duplicate the lead will not visible.But in profile level access they want to access any leads irrespective of ownership.So,is to possible to hide lead whenever lead status is duplicate.Even i had tried everything but won't work can you tell me is it possible
    – Pavan tej
    Commented Mar 9, 2016 at 21:04
  • Hi @crop1645 in my org in sharing rules lead is private.And there is a team called LVS.This team is try to contacts every leads and generate opportunity if lead will qualify and sometimes they get duplicates so my requirement is to whenever this team put account status as duplicate the lead will not visible.But in profile level access they want to access any leads irrespective of ownership.So,is to possible to hide lead whenever lead status is duplicate.Even i had tried everything but won't work can you tell me is it possible
    – Pavan tej
    Commented Mar 9, 2016 at 21:05
  • @Pavantej - when you say 'hide' - hide from what point-of-view? From a specific report? From a specific Lead List View? From search? This could be as simple as adjusting the filter criteria on however this LVS team views Leads
    – cropredy
    Commented Mar 9, 2016 at 21:29

You must log in to answer this question.

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