Skip to main content
Shraddha Gupta が「#Ask An Expert」で質問
Hi Team,

 

Could you please help me in migrating below Trigger to Flow/PB if that is possible -

 

trigger limitCreationsFromZoominfo on Contact (before insert) {

 

//This trigger limit to 25 the number of contacts that can be created from Zoominfo per person per month (#7692)

 

//We can detect that the Contact comes from Zoominfo because: LeadSource = "Zoominfo"

 

//We need to filter the existing contacts (for the count operation) using the fields: 

 

//  CreatedBy = <same user> 

 

//  CreatedDate = <in the last 30 days> 

 

//  LeadOrigin = "Zoominfo"

 

    

 

    

 

//  Users with roles "System Administrator", "Denodo Systems Integration" or "Operations Supervisor" should not be affected by this rule.

 

    Id profileId = UserInfo.getProfileId();

 

    String profileName=[Select Id, Name from Profile where Id=:profileId].Name; 

 

    if ( !profileName.contains('Operations Supervisor') && !profileName.contains('System Administrator') 

 

            && !profileName.contains('Denodo Systems Integration')){

 

            

 

            String userId = UserInfo.getUserId();

 

            Datetime limitDate = System.now().addDays(-30);                            

 

            List<Contact> contactsToInsertFromZoominfo = new List<Contact>();

 

            for(Contact contactToInsert : System.Trigger.new){

 

                if (contactToInsert.LeadSource == 'Zoominfo'){

 

                    contactsToInsertFromZoominfo.add(contactToInsert);

 

                }

 

            }

 

            //if there are insertions from Zoominfo, check the limit

 

            if (contactsToInsertFromZoominfo.size() > 0) {

 

                List<AggregateResult> currentContactsZoominfo = [SELECT Count(Id) currentContacts FROM Contact 

 

                                      WHERE Lead_Origin__c ='Zoominfo' and CreatedDate >= :limitDate and CreatedById = :userId];

 

                for (Contact contactToInsert : contactsToInsertFromZoominfo) {

 

                    if ( (Integer.valueOf(currentContactsZoominfo.get(0).get('currentContacts')) + contactsToInsertFromZoominfo.size()) > 25 ){

 

                        contactToInsert.addError('You can not import more than 25 contacts from Zoominfo in 30 days.');                        

 

                    }   

 

                }

 

                             

 

            }    

 

            

 

     }

 

    

 

      

 

}

 

Basically, this trigger is to restrict specific profile to import contacts from Zoominfo to SFDC if number exceeds 25 in a month. 

 

Any help would be much appreciated.

 

Thanks!
3 件の回答
  1. 2021年1月19日 15:28
    Hi Ankush,

     

    Thanks for sharing this article but I am not sure how I can achieve my requirement with this example flow logic. 

     

    The nuances are -

     

    1. How I can add crietria for Profile in Get Node in order to make the custom checkbox field TRUE

     

    2. Also, how I can count the number of records created in last 30 days with specific Profile User where Lead Source = Zoominfo is not exceeding 25 count?

     

    Thanks!
0/9000