Loading
Käynnistimen luominen liidien näkyvyyden ylläpitämiseksi

Käynnistimen luominen liidien näkyvyyden ylläpitämiseksi

Lisää käynnistin, joka myöntää jako-oikeuden liidin luoneelle henkilölle, vaikka hän ei olisikaan enää liidin omistaja. Jako-oikeuden myöntäminen sallii liidin luojan seurata lähetettä, kun se on muunnettu mahdollisuudeksi.

Vaaditut versiot

Käytettävissä: Lightning Experiencessa

Käytettävissä: Health Cloudin Enterprise- ja Unlimited Edition -versiot

Tärkeää
Tärkeää Sen sijaan, että käytettäisiin liidi- ja mahdollisuusobjekteja lähetteiden hallintaan, käytä Kliininen palvelupyyntö -objektia ja automatisointityökaluja, jotka on laadittu FHIR R4-kohdistetulle kliiniselle datamallille. Jos haluat hyötyä uusista ja parannetuista lähetteiden hallintaominaisuuksista tulevaisuudessa, sinun täytyy käyttää objekteja kliinisessä datamallissa.

Liidi- ja Mahdollisuus-objektien jakoasetukseksi täytyy määrittää Yksityinen tai Julkinen vain luku -asetus käyttääkseen LeadShare- ja OpportunityShare-objekteja.

  1. Valitse Määritykset-valikosta Mukauta ja napsauta Liidi.
  2. Napsauta Käynnistimet ja napsauta sitten Uusi.
  3. Määritä käynnistin syöttämällä tämän esimerkkikoodin tapainen Apex.
    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());
            }
        }  
    }
 
Ladataan
Salesforce Help | Article