• Nirupama Sharma
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 8
    Replies
Hi

I am new to the Apex development,i have never written  a test class for future method Apex class, can someone plz help me in writing the test class
 
public class FutureHandler {
    
    @future
    public static void updaterecs(Map<String,Id> oldManagerQuotaMap1){
        Map<Id,Quota__c> oldMapQuota = new Map<Id,Quota__c>();
        if(null != oldManagerQuotaMap1 && oldManagerQuotaMap1.size() > 0){
            for (aggregateResult result: [Select Manager_Quota__c, Sum(Inside_Sales_Roll_Up__c) 
                                          FROM Quota__c WHERE 
                                          Manager_Quota__c IN: oldManagerQuotaMap1.values() 
                                          GROUP BY Manager_Quota__c]) {
                                              system.debug('result'+result)    ;          
                                              oldMapQuota.put((Id)result.get('Manager_Quota__c'),new Quota__c(Id=(Id)result.get('Manager_Quota__c'),Actual_Amount__c =(Decimal)result.get('expr0')));         
                                          }
            
            for(Id qId : oldManagerQuotaMap1.values()){
                if(!oldMapQuota.containskey(qId)){
                    oldMapQuota.put(qId, new Quota__c(Id = qId,Actual_Amount__c = 0.0));
                }
            }
            
            if(null != oldMapQuota && oldMapQuota.size() > 0){
                update oldMapQuota.values();
            }
            
        }
    }
    
    
    public static void sendOppsForApproval(List<Opportunity> opps){
        
        List<Opportunity> oppsToBeSentForApproval = new List<Opportunity>();
        String monthYear = System.now().format('MMMM-yyyy');
        String month = monthYear.split('-')[0];
        String year = monthYear.split('-')[1];
        Date nextMonthStart = System.today().toStartOfMonth().addMonths(1).toStartOfMonth();
        List<Aggregate_Approval__c> appr = [Select Id from Aggregate_Approval__c where Month__c=:month And Year__c=:year]; 
        Id approvalId;
        if(appr.size()>0){
            approvalId = appr[0].Id;
            
            for(Opportunity opp : opps){
                opp.Aggregate_Approval__c = approvalId;
                opp.Status__c = 'In Approval';
                oppsToBeSentForApproval.add(opp);
            }
            update oppsToBeSentForApproval;
           // List<Approval.LockResult> li = Approval.lock(opps);
            
            Approval.ProcessSubmitRequest oppAggregateApproval = new Approval.ProcessSubmitRequest();
            oppAggregateApproval.setComments('Submitting opportunities for Approval for '+System.now().format('MMMM-yyyy'));
            oppAggregateApproval.setObjectId(approvalId);
            Approval.ProcessResult approvalResult = Approval.process(oppAggregateApproval); 
            
        } 
    }
}

 
Hello all

i am trying to Design a Trigger where it should throw an error upon duplicate record creation, i know this can be achived with Duplicate management, but i have Custom Lookup field(User) which is not showing in the matching rules, Hence i am trying to write trigger, basically i have 3 Custom fields User(Assignedto__c ) which is 
Lookup(User) and other fields are 
Quater_Year__c which is picklist and Month (
Month__c) which is picklist field, 

Please Help with the trigger
trigger contactDuplicatePreventer on Contact(before insert, before update) 
{
	Set<String> setEmailID = new set<String>();
	Set<Id> setContID = new set<ID>();
    for (Contact Contact : System.Trigger.new) 
	{
        if ((Contact.Email != null) &&  (System.Trigger.isInsert ||  (Contact.Email != System.Trigger.oldMap.get(Contact.Id).Email))) 
		{
			setEmailID.add(Contact.Email);
			setContID.add(Contact.id);
		}
    }

	List<Contact> lstCOntact = [select id ,email from contact where email in :setEmailID and id not in :setContID ];
    Map<String, Contact> contactMap = new Map<String, Contact>();

	for(Contact cont : lstCOntact)
	{
		contactMap.put(cont.email, cont);
	}	

    for (Contact Contact : System.Trigger.new) 
	{
        if ((Contact.Email != null) &&  (System.Trigger.isInsert ||  (Contact.Email != System.Trigger.oldMap.get(Contact.Id).Email))) 
		{
			if(contactMap.containsKey(Contact.Email))
			{
				Contact.Email.addError('A Contact with this email address already exists.');
			}
		}	
	}	
}

 
Hello all

I am Trying to Design a Formula where i have Custom Picklist Field called ('Months') where it Contains all 12 months name, Now my Requirement is that when Any Month is Selected, Start Date and End Date Should Auto populate based on Month,

Ex - If i Choose Janaury, Start Date and End Date of January Should Auto Populate in the thosed Custom Fields, How Do i Achive this Functionality
Hello everyone

I need a small help in bulkifying the below code, Basically what this trigger does is when country is populated, it checks with the Formula Field (Updated_Region__c) and assigns with the Correct Region Field, Ex - when Updated Region is Middle east(ME) then the custom fields related to ME(Lead_No_Region_ME__c) gets incremented with 1,2,3....

Now i hear this is not a best pratices for deploying in the production, because when bulk records gets updated, the code may fail, but to my suprise i have Written a Test class with code coverage of 98%, Could any please help with the solution or suggestion
 
trigger LeadIncrement on Lead (before insert,Before Update) {
    if(trigger.isBefore && (trigger.isInsert || trigger.isUpdate)) {
        List<Lead> leadList = [Select Id,Lead_No_Region_IN__c From Lead Where Region__c = 'India'];
        For(Lead l : trigger.New) {
            if(l.Region__c == 'India') {
                if(leadList.size() > 0){
                    l.Lead_No_Region_IN__c = leadList.size()+0;   
                } else {
                    l.Lead_No_Region_IN__c = 1;
                }
            }
        }
        List<Lead> leadListt = [Select Id,Lead_No_Region_USA__c From Lead Where Region__c = 'US'];
        For(Lead m : trigger.New) {
            if(m.Region__c == 'US') {
                if(leadListt.size() > 0){
                    m.Lead_No_Region_USA__c = leadListt.size()+0;   
                } else {
                    m.Lead_No_Region_USA__c = 1;
                }
            }
        } 
        List<Lead> leadListm = [Select Id,Lead_No_Region_EU__c From Lead Where Region__c = 'EU'];
        For(Lead n : trigger.New) {
            if(n.Region__c == 'EU') {
                if(leadListm.size() > 0){
                    n.Lead_No_Region_EU__c = leadListm.size()+0;   
                } else {
                    n.Lead_No_Region_EU__c = 1;
                }
            }
        } 
        List<Lead> leadListo = [Select Id,Lead_No_Region_EU__c From Lead Where Region__c = 'SEA'];
        For(Lead o : trigger.New) {
            if(o.Region__c == 'SEA') {
                if(leadListo.size() > 0){
                    o.Lead_No_Region_SEA__c = leadListo.size()+0;   
                } else {
                    o.Lead_No_Region_SEA__c = 1;
                }
            }
        }
        List<Lead> leadListp = [Select Id,Lead_No_Region_ME__c From Lead Where Region__c = 'ME'];
        For(Lead p : trigger.New) {
            if(p.Region__c == 'ME') {
                if(leadListp.size() > 0){
                    p.Lead_No_Region_ME__c = leadListp.size()+0;   
                } else {
                    p.Lead_No_Region_ME__c = 1;
                }
            }
        } 
        
    }					
}

Test Class
 
@isTest
public class LeadIncrementV3Test {
    @isTest
    public static void LeadIncrementV3TestMethod() {
        List<Lead> leadList = new List<Lead>();

        Lead l = new Lead();
        l.Country = 'India';
        l.Company = 'Test';
        l.LastName = 'testLast';
        l.Status = 'Enquiry';
        leadList.add(l);

        Lead l1 = new Lead();
        l1.Country = 'India';
        l1.Company = 'Test1';
        l1.LastName = 'testLast1';
        l1.Status = 'Enquiry';
        leadList.add(l1);

        Lead l2 = new Lead();
        l2.Country = 'US';
        l2.Company = 'Test2';
        l2.LastName = 'testLast2';
        l2.Status = 'Enquiry';
        leadList.add(l2);

        Lead l21 = new Lead();
        l21.Country = 'USA';
        l21.Company = 'Test21';
        l21.LastName = 'testLast21';
        l21.Status = 'Enquiry';
        leadList.add(l21);

        Lead l3 = new Lead();
        l3.Country = 'Brazil';
        l3.Company = 'Test3';
        l3.LastName = 'testLast3';
        l3.Status = 'Enquiry';
        leadList.add(l3);

        Lead l31 = new Lead();
        l31.Country = 'Belgium';
        l31.Company = 'Test31';
        l31.LastName = 'testLast31';
        l31.Status = 'Enquiry';
        leadList.add(l31);

        Lead l4 = new Lead();
        l4.Country = 'Thailand';
        l4.Company = 'Test4';
        l4.LastName = 'testLast4';
        l4.Status = 'Enquiry';
        leadList.add(l4);

        Lead l41 = new Lead();
        l41.Country = 'Japan';
        l41.Company = 'Test41';
        l41.LastName = 'testLast41';
        l41.Status = 'Enquiry';
        leadList.add(l41);

        Lead l5 = new Lead();
        l5.Country = 'Iran';
        l5.Company = 'Test5';
        l5.LastName = 'testLast5';
        l5.Status = 'Enquiry';
        leadList.add(l5);

        Lead l51 = new Lead();
        l51.Country = 'Kuwait';
        l51.Company = 'Test51';
        l51.LastName = 'testLast51';
        l51.Status = 'Enquiry';
        leadList.add(l51);  
        
        Insert leadList;
    }
}

​​​​​​​
Hello All

Need help in designing a trigger, i am working on a Force.com where i have builting all the objects from the scratch (Leads,Accounts,Opportunities, Quotes,Quotelineitems,Products), Now My requirement is When Sync checkbox is checked, Products in the QuoteLineItems needs to be synced to opportunity

i am trying to take reference from these two links
link - https://www.brcline.com/blog/sync-quotes-using-apex
Link 2- https://www.brcline.com/blog/sync-quotes-using-apex
Hello all

i am trying to Design a Trigger where it should throw an error upon duplicate record creation, i know this can be achived with Duplicate management, but i have Custom Lookup field(User) which is not showing in the matching rules, Hence i am trying to write trigger, basically i have 3 Custom fields User(Assignedto__c ) which is 
Lookup(User) and other fields are 
Quater_Year__c which is picklist and Month (
Month__c) which is picklist field, 

Please Help with the trigger
trigger contactDuplicatePreventer on Contact(before insert, before update) 
{
	Set<String> setEmailID = new set<String>();
	Set<Id> setContID = new set<ID>();
    for (Contact Contact : System.Trigger.new) 
	{
        if ((Contact.Email != null) &&  (System.Trigger.isInsert ||  (Contact.Email != System.Trigger.oldMap.get(Contact.Id).Email))) 
		{
			setEmailID.add(Contact.Email);
			setContID.add(Contact.id);
		}
    }

	List<Contact> lstCOntact = [select id ,email from contact where email in :setEmailID and id not in :setContID ];
    Map<String, Contact> contactMap = new Map<String, Contact>();

	for(Contact cont : lstCOntact)
	{
		contactMap.put(cont.email, cont);
	}	

    for (Contact Contact : System.Trigger.new) 
	{
        if ((Contact.Email != null) &&  (System.Trigger.isInsert ||  (Contact.Email != System.Trigger.oldMap.get(Contact.Id).Email))) 
		{
			if(contactMap.containsKey(Contact.Email))
			{
				Contact.Email.addError('A Contact with this email address already exists.');
			}
		}	
	}	
}

 
Hello all

I am Trying to Design a Formula where i have Custom Picklist Field called ('Months') where it Contains all 12 months name, Now my Requirement is that when Any Month is Selected, Start Date and End Date Should Auto populate based on Month,

Ex - If i Choose Janaury, Start Date and End Date of January Should Auto Populate in the thosed Custom Fields, How Do i Achive this Functionality
Hello all

I am New to the Aura Componets, i am trying to Build Tree Structure Pictorical Diagram where related contacts should show 
for Parent Account, any help would highly be appriated

User-added imageMy Code
Apex code

public class AccountTreeMapClass {

   @AuraEnabled
   public static account getaccountData(string recId){
       return [select id, name, Company_Head__c,Sales_Team__c,SalesManager__c,Department__c,Director__c, HR_Team__c, Manager1__c, Team_Manager1__c,
               Manager2__c, Team_Manager2__c From account where id=: recId];
   } 
}
-----------------------------

Component


<aura:component controller="AccountTreeMapClass" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    <aura:attribute name="acc" type="Account"/>
    <aura:attribute name="recordId"  type="String" default = "0012w0000085dU4AAI" />
    <aura:handler event="force:refreshView" action="{! c.doInit}" />
    <aura:handler name="init" value="{! this}" action="{! c.doInit}" />
    
    
    <lightning:layout>
        <div class="slds-scrollable" style="height:24rem;width:50rem;background-color: antiquewhite;">
            <body style="margin-top: -19px;">
                <div class="tree"  style="width:200%">
                    <aura:if isTrue="{!not(empty(v.acc.Department__c))}">																																
                        
                        <ul>
                            <li>
                                <p class="bg1"><ui:outputText value="{!v.acc.Department__c}"></ui:outputText> Group</p>
                                <ul>
                                    <li>
                                        <p class="slds-text-heading--medium"  style="background-color: yellow;width: 65px;word-break: break-all;">CEO</p> 
                                        <aura:if isTrue="{!not(empty(v.acc.Company_Head__c))}">
                                            <ul>
                                                <li  class="testry">
                                                    <p class="slds-text-heading--medium" style="background-color: lightblue;width: 65px;word-break: break-all;">{!v.acc.Company_Head__c}</p>
                                                </li>
                                            </ul>
                                        </aura:if>
                                    </li>
                                    <li>
                                        <p class="slds-text-heading--medium"  style="background-color: yellow;Width: 65px;word-break: break-all;">Director</p>			
                                        <aura:if isTrue="{!not(empty(v.acc.Director__c))}">
                                            <ul>
                                                <li>
                                                    <p class="slds-text-heading--medium" style="background-color: lightblue;width: 65px;word-break: break-all;"> {!v.acc.Director__c}</p>
                                                </li>
                                            </ul>
                                        </aura:if>
                                    </li>
                                    <li>
                                        <p class="slds-text-heading--medium"  style="background-color: yellow;width: 65px;word-break: break-all;">HR Department</p>
                                        <aura:if isTrue="{!not(empty(v.acc.HR_Team__c))}">
                                            <ul>
                                                <li>
                                                    <p class="slds-text-heading--medium" style="background-color: lightblue;width: 65px;word-break: break-all;"> {!v.acc.HR_Team__c}</p>
                                                </li>
                                            </ul>
                                        </aura:if>
                                    </li>
                                    
                                    <li>
                                        <p class="slds-text-heading--medium"  style="background-color: yellow;width: 65px;word-break: break-all;">Project Manager1</p>
                                        <aura:if isTrue="{!not(empty(v.acc.Manager1__c))}">
                                            <ul>
                                                
                                                <li>
                                                    <p class="slds-text-heading--medium" style="background-color: lightblue;width: 65px;word-break: break-all;">{!v.acc.Manager1__c}</p>
                                                    <ul>
                                                        <li>
                                                            <p class="slds-text-heading--medium" style="background-color: lightgray;width: 65px;word-break: break-all;">{!v.acc.Team_Manager1__c}</p>
                                                        </li>
                                                        
                                                    </ul>
                                                </li>
                                            </ul>
                                        </aura:if>
                                    </li>
                                    <li>
                                        <p class="slds-text-heading--medium" style="background-color: yellow;width: 65px;word-break: break-all;">Project Manager2</p>
                                        <aura:if isTrue="{!not(empty(v.acc.Manager2__c))}">
                                            <ul>
                                                <li style="background-color: antiquewhite;">
                                                    <p class="slds-text-heading--medium" style="background-color: lightblue;width: 65px;word-break: break-all;"> {!v.acc.Manager2__c}</p>
                                                    <ul>
                                                        <li style="background-color: antiquewhite;">
                                                            <p class="slds-text-heading--medium" style="background-color: lightgray;width: 65px;word-break: break-all;">Yeshwanth</p><!--{!v.keyResult.Team_Manager2__c}-->
                                                        </li>
                                                        <li style="background-color: antiquewhite;">
                                                            <p class="slds-text-heading--medium" style="background-color: lightgray;width: 65px;word-break: break-all;">Sai</p>
                                                        </li>
                                                        
                                                    </ul>
                                                </li>
                                                
                                            </ul>
                                        </aura:if>
                                    </li>
                                    <li>
                                        <p class="slds-text-heading--medium"  style="background-color: yellow;width: 65px;word-break: break-all;">Sales Department</p>
                                        <aura:if isTrue="{!not(empty(v.acc.Sales_Team__c))}">
                                            <ul>
                                                <li class="test" style="background-color: antiquewhite;">
                                                    <p class="slds-text-heading--medium" style="background-color: lightblue;width: 65px;word-break: break-all;">{!v.acc.Sales_Team__c}</p>
                                                </li>
                                            </ul>
                                        </aura:if>
                                    </li>
                                    <li>
                                        <p class="slds-text-heading--medium"  style="background-color: yellow;width: 65px;word-break: break-all;">Sales Project Manager</p>
                                        <aura:if isTrue="{!not(empty(v.acc.SalesManager__c))}">
                                            <ul>
                                                <li class="test">
                                                    <p class="slds-text-heading--medium" style="background-color: lightblue;width: 65px;word-break: break-all;">{!v.acc.SalesManager__c}</p>
                                                </li>
                                            </ul>
                                        </aura:if>
                                    </li>
                                    
                                </ul>
                            </li>
                        </ul>
                    </aura:if>
                </div>
            </body>
        </div>
        
    </lightning:layout>
    
    <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
    
    <div class="tree11" >
        <body>
            <a style="background-color: lightgreen;font-weight: 300;font-size: 17px;border: 2px solid red;border-radius: 4px;">Account</a>
            <img src="{!$Resource.Capture1}" style="margin-left: 126px;margin-top: -43px;width: 80px;margin-left: 0px;height: 38px;margin-top: -10px;border: 2px solid aliceblue;border-radius: 14px;"/>
            
            <ul>
                <li>
                    <a  style="background-color: yellow;font-weight: 300;font-size: 17px;border: 2px solid red;border-radius: 4px;">Contact1</a>
                    <ul>
                        <li>
                            <a  style="background-color: lightblue;font-weight: 300;font-size: 17px;border: 2px solid red;border-radius: 4px;"> {!v.acc.Company_Head__c}</a>
                        </li>
                    </ul>
                </li>
                <li>
                    <a style="background-color: yellow;font-weight: 300;font-size: 17px;border: 2px solid red;border-radius: 4px;">Contact2</a>
                    <ul>
                        <li>
                            <a style="background-color: lightblue;font-weight: 300;font-size: 17px;border: 2px solid red;border-radius: 4px;"> {!v.acc.Director__c}</a>
                        </li>
                    </ul>
                </li>
                <li>
                    <a style="background-color: yellow;font-weight: 300;font-size: 17px;border: 2px solid red;border-radius: 4px;">Contact3</a>
                    <ul>
                        <li>
                            <a style="background-color: lightblue;font-weight: 300;font-size: 17px;border: 2px solid red;border-radius: 4px;"> {!v.acc.HR_Team__c}</a>
                        </li>
                    </ul>
                </li>
                
                <li>
                    <a  style="background-color: yellow;font-weight: 300;font-size: 17px;border: 2px solid red;border-radius: 4px;">Contact4</a>
                    <ul>
                        <li>
                            <a  style="background-color: lightblue;font-weight: 300;font-size: 17px;border: 2px solid red;border-radius: 4px;">Contact5</a>
                            <ul>
                                <li>
                                    <a  style="background-color: lightgray;font-weight: 300;font-size: 17px;border: 2px solid red;border-radius: 4px;">Contact6</a><!--{!v.keyResult.Team_Manager1__c}-->
                                </li>
                                <li>
                                    <a  style="background-color: lightgray;font-weight: 300;font-size: 17px;border: 2px solid red;border-radius: 4px;">Contact7</a>
                                </li>
                                <li>
                                    <a style="background-color: lightgray;font-weight: 300;font-size: 17px;border: 2px solid red;border-radius: 4px;">Contact8</a>
                                </li>
                                <li>
                                    <a style="background-color: lightgray;font-weight: 300;font-size: 17px;border: 2px solid red;border-radius: 4px;">Contact9</a>
                                </li>
                            </ul>
                        </li>
                    </ul>
                </li>
                <li>
                    <a style="background-color: yellow;font-weight: 300;font-size: 17px;border: 2px solid red;border-radius: 4px;">Project Manager2</a>
                    <ul>
                        <li>
                            <a  style="background-color: lightblue;font-weight: 300;font-size: 17px;border: 2px solid red;border-radius: 4px;"> {!v.acc.Manager2__c}</a>
                            <ul>
                                <li>
                                    <a  style="background-color: lightgray;font-weight: 300;font-size: 17px;border: 2px solid red;border-radius: 4px;">Yeshwanth</a><!--{!v.keyResult.Team_Manager2__c}-->
                                </li>
                                <li>
                                    <a  style="background-color: lightgray;font-weight: 300;font-size: 17px;border: 2px solid red;border-radius: 4px;">Sai</a>
                                </li>
                                
                            </ul>
                        </li>
                    </ul>
                </li>
                <li>
                    
                    <a   style="background-color: yellow;font-weight: 300;font-size: 17px;border: 2px solid red;border-radius: 4px;">Sales Department</a>
                    <ul>
                        <li>
                            <a  style="background-color: lightblue;font-weight: 300;font-size: 17px;border: 2px solid red;border-radius: 4px;">Ila, Nikhil</a>
                        </li>
                    </ul>
                </li>
                <li>
                    <a  style="background-color: yellow;font-weight: 300;font-size: 17px;border: 2px solid red;border-radius: 4px;">Sales Project Manager</a>
                    <ul>
                        <li>
                            <a style="background-color: lightblue;font-weight: 300;font-size: 17px;border: 2px solid red;border-radius: 4px;">Haider</a>
                        </li>
                    </ul>
                </li>
                
            </ul>
        </body>
    </div>
    
</aura:component>

----------------------------

J.s code

({
    doInit: function (component, event, helper) {
        var action= component.get("c.getaccountData");
        action.setParams({
            recId: component.get("v.recordId")
        });
        action.setCallback(this, function(res) {
            var state=res.getState();
            var r = res.getReturnValue();
            if(state==="SUCCESS"){
                component.set("v.acc", r);
            }
        });
     $A.enqueueAction(action);              
    },
   
    recordUpdate: function (component, event, helper) {
        var accountFields = component.get("v.keyResult");
        var items = [{
            "label": "Department Of Proseraa",
            "name": "1",
            "expanded": true,
            "items": [{
                "label": "CEO",
                "name": "2",
                "expanded": true,
                "items" :[{
                    "label": accountFields.Company_Head__c,
                    "name": "3",
                    "expanded": true,
                }]
            },{
                "label": "Director",
                "name": "4",
                "expanded": true,
                "items" :[{
                    "label": accountFields.Director__c,
                    "name": "3",
                    "expanded": true,
                }]
            },{
                "label": "HR Team",
                "name": "5",
                "expanded": true,
                "items" :[{
                    "label": accountFields.HR_Team__c,
                    "name": "3",
                    "expanded": true,
                }]
            },{
                "label": "Project Manager",
                "name": "6",
                "expanded": true,
                "items" :[{
                    "label": accountFields.Manager1__c,
                    "name": "7",
                    "expanded": true,
                    "items" :[{
                        "label": accountFields.Team_Manager1__c,
                        "name": "8",
                        "expanded": true,
                    }]
                },{
                    "label":  accountFields.Manager2__c,
                    "name": "9",
                    "expanded": true,
                   
                    "items" :[{
                        "label": accountFields.Team_Manager2__c,
                        "name": "10",
                        "expanded": true,
                        'tag': 'button',
                    }]
                }]
            }],
           
           
        }];
        component.set('v.items', items);
    },
})

----------------------

css


.THIS .tree ul {
    padding-top: 20px; position: relative;
    transition: all 0.5s;
}


.THIS .tree li {
    float: left; text-align: center;
    list-style-type: none;
    position: relative;
    padding: 40px 0px 0 3px;
   
    transition: all 0.5s;
    margin-left: -1px;
}

.THIS .tree li::before, .THIS .tree li::after{
    content: '';
    position: absolute; top: 0; right: 50%;
    border-top: 2px solid blue;
    width: 55%; height: 40px;
}

.THIS .tree li::after{
    right: auto; left: 50%;
    border-left: 2px solid blue;
}



/*We need to remove left-right connectors from elements without
any siblings*/
.THIS .tree li:only-child::after, .THIS .tree li:only-child::before {
    display: none;
}

/*Remove space from the top of single children*/
.THIS .tree li:only-child{ padding-top: 0;}

/*Remove left connector from first child and
right connector from last child*/
.THIS .tree li:first-child::before, .THIS .tree li:last-child::after{
    border: 0 none;
}
/*Adding back the vertical connector to the last nodes*/
.THIS .tree li:last-child::before{
    border-right: 2px solid blue;
    border-radius: 0 5px 0 0;}
.THIS .tree li:first-child::after{
    border-radius: 10px 0 0 0;
}

/*Time to add downward connectors from parents*/
.THIS .tree ul ul::before{
    content: '';
    position: absolute; top: 0; left: 49%;
    border-left: 3px solid blue;
    width: 0; height: 20px;
}

.THIS .test{
    position: absolute; top: 0;
}

.THIS .bg1{
    background-color: lightgreen;
}


.THIS .tree ul ul:empty::before{
    display: none;
}
.THIS .tree li p{
    border: 1px solid red;
    padding: 5px 10px;
    text-decoration: none;
    color: #666;
    font-family: arial, verdana, tahoma;
    font-size: 10px;
    display: inline-block;
    border-radius: 5px;
    transition: all 0.5s;
    border-right: 2px solid red;
}

/*Time for some hover effects*/
/*We will apply the hover effect the the lineage of the element also*/
.THIS .tree li p:hover, .THIS .tree li p:hover+ul li p {
    background: #c8e4f8; color: #000; border: 1px solid #94a0b4;
}
/*Connector styles on hover*/
.THIS .tree li p:hover+ul li::after,
.THIS .tree li p:hover+ul li::before,
.THIS .tree li p:hover+ul::before,
.THIS .tree li p:hover+ul ul::before{
    border-color:  #94a0b4;
}

.THIS.tree11{
    margin:0 auto;
    width: 100%;
}

.THIS.tree11 ul{
    padding: 10px 5px 0 5px;
    position: relative;
    z-index: 1;
}


.THIS.tree11 li{
    margin-left: 28px;
    list-style-type: none;
    position: relative;
    padding: 5px 5px 0 5px;
}

.THIS.tree11 li::after{
    content: '';
    position: absolute;
    border-bottom: 3px solid #c61f1f;
    border-left: 3px solid #c61f1f;
    height: 33px;
    width: 15px;
    right: auto;
    left: -10px;
    top: -11px;
    padding: -2px 10px;
    border-radius:2px;
}

-----------------------------------------------------

<aura:application extends="Force:slds">
    <c:TreePicture />
</aura:application>


 
Hi

I am new to the Apex development,i have never written  a test class for future method Apex class, can someone plz help me in writing the test class
 
public class FutureHandler {
    
    @future
    public static void updaterecs(Map<String,Id> oldManagerQuotaMap1){
        Map<Id,Quota__c> oldMapQuota = new Map<Id,Quota__c>();
        if(null != oldManagerQuotaMap1 && oldManagerQuotaMap1.size() > 0){
            for (aggregateResult result: [Select Manager_Quota__c, Sum(Inside_Sales_Roll_Up__c) 
                                          FROM Quota__c WHERE 
                                          Manager_Quota__c IN: oldManagerQuotaMap1.values() 
                                          GROUP BY Manager_Quota__c]) {
                                              system.debug('result'+result)    ;          
                                              oldMapQuota.put((Id)result.get('Manager_Quota__c'),new Quota__c(Id=(Id)result.get('Manager_Quota__c'),Actual_Amount__c =(Decimal)result.get('expr0')));         
                                          }
            
            for(Id qId : oldManagerQuotaMap1.values()){
                if(!oldMapQuota.containskey(qId)){
                    oldMapQuota.put(qId, new Quota__c(Id = qId,Actual_Amount__c = 0.0));
                }
            }
            
            if(null != oldMapQuota && oldMapQuota.size() > 0){
                update oldMapQuota.values();
            }
            
        }
    }
    
    
    public static void sendOppsForApproval(List<Opportunity> opps){
        
        List<Opportunity> oppsToBeSentForApproval = new List<Opportunity>();
        String monthYear = System.now().format('MMMM-yyyy');
        String month = monthYear.split('-')[0];
        String year = monthYear.split('-')[1];
        Date nextMonthStart = System.today().toStartOfMonth().addMonths(1).toStartOfMonth();
        List<Aggregate_Approval__c> appr = [Select Id from Aggregate_Approval__c where Month__c=:month And Year__c=:year]; 
        Id approvalId;
        if(appr.size()>0){
            approvalId = appr[0].Id;
            
            for(Opportunity opp : opps){
                opp.Aggregate_Approval__c = approvalId;
                opp.Status__c = 'In Approval';
                oppsToBeSentForApproval.add(opp);
            }
            update oppsToBeSentForApproval;
           // List<Approval.LockResult> li = Approval.lock(opps);
            
            Approval.ProcessSubmitRequest oppAggregateApproval = new Approval.ProcessSubmitRequest();
            oppAggregateApproval.setComments('Submitting opportunities for Approval for '+System.now().format('MMMM-yyyy'));
            oppAggregateApproval.setObjectId(approvalId);
            Approval.ProcessResult approvalResult = Approval.process(oppAggregateApproval); 
            
        } 
    }
}

 
Hello all

i am trying to Design a Trigger where it should throw an error upon duplicate record creation, i know this can be achived with Duplicate management, but i have Custom Lookup field(User) which is not showing in the matching rules, Hence i am trying to write trigger, basically i have 3 Custom fields User(Assignedto__c ) which is 
Lookup(User) and other fields are 
Quater_Year__c which is picklist and Month (
Month__c) which is picklist field, 

Please Help with the trigger
trigger contactDuplicatePreventer on Contact(before insert, before update) 
{
	Set<String> setEmailID = new set<String>();
	Set<Id> setContID = new set<ID>();
    for (Contact Contact : System.Trigger.new) 
	{
        if ((Contact.Email != null) &&  (System.Trigger.isInsert ||  (Contact.Email != System.Trigger.oldMap.get(Contact.Id).Email))) 
		{
			setEmailID.add(Contact.Email);
			setContID.add(Contact.id);
		}
    }

	List<Contact> lstCOntact = [select id ,email from contact where email in :setEmailID and id not in :setContID ];
    Map<String, Contact> contactMap = new Map<String, Contact>();

	for(Contact cont : lstCOntact)
	{
		contactMap.put(cont.email, cont);
	}	

    for (Contact Contact : System.Trigger.new) 
	{
        if ((Contact.Email != null) &&  (System.Trigger.isInsert ||  (Contact.Email != System.Trigger.oldMap.get(Contact.Id).Email))) 
		{
			if(contactMap.containsKey(Contact.Email))
			{
				Contact.Email.addError('A Contact with this email address already exists.');
			}
		}	
	}	
}

 
Hello all

I am Trying to Design a Formula where i have Custom Picklist Field called ('Months') where it Contains all 12 months name, Now my Requirement is that when Any Month is Selected, Start Date and End Date Should Auto populate based on Month,

Ex - If i Choose Janaury, Start Date and End Date of January Should Auto Populate in the thosed Custom Fields, How Do i Achive this Functionality
Hello everyone

I need a small help in bulkifying the below code, Basically what this trigger does is when country is populated, it checks with the Formula Field (Updated_Region__c) and assigns with the Correct Region Field, Ex - when Updated Region is Middle east(ME) then the custom fields related to ME(Lead_No_Region_ME__c) gets incremented with 1,2,3....

Now i hear this is not a best pratices for deploying in the production, because when bulk records gets updated, the code may fail, but to my suprise i have Written a Test class with code coverage of 98%, Could any please help with the solution or suggestion
 
trigger LeadIncrement on Lead (before insert,Before Update) {
    if(trigger.isBefore && (trigger.isInsert || trigger.isUpdate)) {
        List<Lead> leadList = [Select Id,Lead_No_Region_IN__c From Lead Where Region__c = 'India'];
        For(Lead l : trigger.New) {
            if(l.Region__c == 'India') {
                if(leadList.size() > 0){
                    l.Lead_No_Region_IN__c = leadList.size()+0;   
                } else {
                    l.Lead_No_Region_IN__c = 1;
                }
            }
        }
        List<Lead> leadListt = [Select Id,Lead_No_Region_USA__c From Lead Where Region__c = 'US'];
        For(Lead m : trigger.New) {
            if(m.Region__c == 'US') {
                if(leadListt.size() > 0){
                    m.Lead_No_Region_USA__c = leadListt.size()+0;   
                } else {
                    m.Lead_No_Region_USA__c = 1;
                }
            }
        } 
        List<Lead> leadListm = [Select Id,Lead_No_Region_EU__c From Lead Where Region__c = 'EU'];
        For(Lead n : trigger.New) {
            if(n.Region__c == 'EU') {
                if(leadListm.size() > 0){
                    n.Lead_No_Region_EU__c = leadListm.size()+0;   
                } else {
                    n.Lead_No_Region_EU__c = 1;
                }
            }
        } 
        List<Lead> leadListo = [Select Id,Lead_No_Region_EU__c From Lead Where Region__c = 'SEA'];
        For(Lead o : trigger.New) {
            if(o.Region__c == 'SEA') {
                if(leadListo.size() > 0){
                    o.Lead_No_Region_SEA__c = leadListo.size()+0;   
                } else {
                    o.Lead_No_Region_SEA__c = 1;
                }
            }
        }
        List<Lead> leadListp = [Select Id,Lead_No_Region_ME__c From Lead Where Region__c = 'ME'];
        For(Lead p : trigger.New) {
            if(p.Region__c == 'ME') {
                if(leadListp.size() > 0){
                    p.Lead_No_Region_ME__c = leadListp.size()+0;   
                } else {
                    p.Lead_No_Region_ME__c = 1;
                }
            }
        } 
        
    }					
}

Test Class
 
@isTest
public class LeadIncrementV3Test {
    @isTest
    public static void LeadIncrementV3TestMethod() {
        List<Lead> leadList = new List<Lead>();

        Lead l = new Lead();
        l.Country = 'India';
        l.Company = 'Test';
        l.LastName = 'testLast';
        l.Status = 'Enquiry';
        leadList.add(l);

        Lead l1 = new Lead();
        l1.Country = 'India';
        l1.Company = 'Test1';
        l1.LastName = 'testLast1';
        l1.Status = 'Enquiry';
        leadList.add(l1);

        Lead l2 = new Lead();
        l2.Country = 'US';
        l2.Company = 'Test2';
        l2.LastName = 'testLast2';
        l2.Status = 'Enquiry';
        leadList.add(l2);

        Lead l21 = new Lead();
        l21.Country = 'USA';
        l21.Company = 'Test21';
        l21.LastName = 'testLast21';
        l21.Status = 'Enquiry';
        leadList.add(l21);

        Lead l3 = new Lead();
        l3.Country = 'Brazil';
        l3.Company = 'Test3';
        l3.LastName = 'testLast3';
        l3.Status = 'Enquiry';
        leadList.add(l3);

        Lead l31 = new Lead();
        l31.Country = 'Belgium';
        l31.Company = 'Test31';
        l31.LastName = 'testLast31';
        l31.Status = 'Enquiry';
        leadList.add(l31);

        Lead l4 = new Lead();
        l4.Country = 'Thailand';
        l4.Company = 'Test4';
        l4.LastName = 'testLast4';
        l4.Status = 'Enquiry';
        leadList.add(l4);

        Lead l41 = new Lead();
        l41.Country = 'Japan';
        l41.Company = 'Test41';
        l41.LastName = 'testLast41';
        l41.Status = 'Enquiry';
        leadList.add(l41);

        Lead l5 = new Lead();
        l5.Country = 'Iran';
        l5.Company = 'Test5';
        l5.LastName = 'testLast5';
        l5.Status = 'Enquiry';
        leadList.add(l5);

        Lead l51 = new Lead();
        l51.Country = 'Kuwait';
        l51.Company = 'Test51';
        l51.LastName = 'testLast51';
        l51.Status = 'Enquiry';
        leadList.add(l51);  
        
        Insert leadList;
    }
}

​​​​​​​