Vous êtes ici :
Création d'un déclencheur pour maintenir la visibilité des pistes
Ajoutez un déclencheur qui accorde l'accès en partage à la personne qui a créé la piste, même lorsqu'elle n'est plus propriétaire de la piste. L'octroi de l'accès en partage permet au créateur de la piste de suivre la recommandation une fois convertie en opportunité.
Éditions requises
Disponible avec : Lightning Experience Disponible avec : éditions Enterprise et Unlimited avec Health Cloud |
Important Au lieu d'utiliser les objets Piste et Opportunité pour gérer les recommandations, utilisez l'objet Demande de service clinique et les outils d'automatisation élaborés pour le modèle de données cliniques conforme FHIR R4. Pour bénéficier à l'avenir de fonctionnalités nouvelles et avancées de gestion des recommandations, vous devez utiliser des objets dans le Modèle de données cliniques.
Pour accéder aux objets LeadShare et OpportunityShare, le partage des objets Lead et Opportunity doit être défini sur Privé ou Accès public en lecture seule.
- Dans Configuration, sélectionnez Personnaliser, puis cliquez sur Piste.
- Cliquez sur Déclencheurs, puis sur Nouveau.
-
Pour définir votre déclencheur, saisissez un code Apex similaire à cet exemple de code.
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()); } } }
Cet article a-t-il résolu votre problème ?
Dites-nous ce que nous pouvons améliorer !
