Erstellen eines Auslösers zum Aufrechterhalten der Leadsichtbarkeit
Fügen Sie einen Auslöser hinzu, der der Person, die den Lead erstellt hat, Freigabezugriff gewährt, selbst wenn sie nicht mehr der Inhaber des Leads ist. Durch das Gewähren von Freigabezugriff kann der Ersteller des Leads die Überweisung nach der Konvertierung in eine Opportunity verfolgen.
Erforderliche Editionen
Verfügbarkeit: Lightning Experience
Verfügbarkeit: Enterprise und Unlimited Edition mit Health Cloud
Wichtig Statt Lead- und Opportunity-Objekte zum Verwalten von Überweisungen zu verwenden, verwenden Sie das Objekt "Anforderung klinischer Services" und Automatisierungstools, die für das FHIR R4-konforme klinische Datenmodell entwickelt wurden. Damit Sie künftig von neuen und erweiterten Funktionen der Überweisungsverwaltung profitieren können, müssen Sie Objekte im klinischen Datenmodell verwenden.
Für den Zugriff auf die Objekte "LeadShare" und "OpportunityShare" muss die Freigabe für die Objekte "Lead" und "Opportunity" auf "Privat" oder "Öffentlicher Lesezugriff" festgelegt sein.
Wählen Sie unter "Setup" die Option Anpassen aus und klicken Sie dann auf Lead.
Klicken Sie auf Auslöser und dann auf Neu.
Geben Sie zum Definieren Ihres Auslösers Apex Code ein, der diesem Beispielcode ähnelt.
trigger ReferralShare on Lead (after update) {
for(Lead lead : Trigger.new){
try{
Lead oldLead = Trigger.oldMap.get(lead.Id);
// find the Group that the Lead creator is part of
Group grp = [SELECT Id FROM Group WHERE Type='RoleAndSubordinates'
AND RelatedId in (select UserRoleId from User where Id= :lead.CreatedById)];
// Lead trigger sharing example - if the owner changed and the owner is different than the creator,
// share the Lead with the Group of the user that created the Lead
if (lead.CreatedById!=lead.OwnerId && lead.OwnerId!=oldLead.OwnerId){
// create a new LeadShare record for the creator's Group
LeadShare leadShare = new LeadShare(LeadId=lead.Id, UserOrGroupId=grp.Id, LeadAccessLevel='Read', RowCause='Manual');
Database.SaveResult save = Database.insert(leadShare,false);
if (save.isSuccess()){
System.debug(LoggingLevel.ERROR, 'SAVE RESULT SUCCESS');
}
else {
for(Database.Error err : save.getErrors()){
System.debug(LoggingLevel.ERROR, 'SAVE RESULT ERROR: ' + err.getMessage());
}
}
}
// Opportunity sharing example - on Lead conversion, add an Opportunity sharing record for the Group of
// the user that created the Lead
if (lead.IsConverted){
// create a new OpportunityShare record for the creator's Group
OpportunityShare opptyShare = new OpportunityShare(OpportunityId=lead.ConvertedOpportunityId, UserOrGroupId=grp.Id,
OpportunityAccessLevel='Read', RowCause='Manual');
Database.SaveResult save = Database.insert(opptyShare,false);
if (save.isSuccess()){
System.debug(LoggingLevel.ERROR, 'SAVE RESULT SUCCESS');
}
else {
for(Database.Error err : save.getErrors()){
System.debug(LoggingLevel.ERROR, 'SAVE RESULT ERROR: ' + err.getMessage());
}
}
}
}
catch(Exception ex){
System.debug(LoggingLevel.ERROR, 'EXCEPTION: ' + ex.getMessage());
}
}
}
Konnten Sie Ihr Problem mithilfe dieses Artikels lösen?
Geben Sie uns Feedback, damit wir uns verbessern können.
Laden
Salesforce Help | Article
Cookie Consent Manager
Cookie Consent Manager
General Information
Required Cookies
Functional Cookies
Advertising Cookies
General Information
We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required Cookies
Always Active
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional Cookies
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising Cookies
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.