• m 10
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 3
    Replies
please find attached screenshot requirement belowUser-added image
Public class AccountTriggerHnadler{
    Public static void UpdateAmountNew(List<Account> accList){
        Set<ID> acccidSet = new Set<Id>();
        Map<id,Account> AccMap = new Map<id,Account>();
        For(Account acc: accList){
            if(acc.ParentId!=NULL){
                AcccidSet.add(acc.ParentId);
                System.debug('AcccidSet'+AcccidSet);
            }
            System.debug('accList'+accList);
        }
     
       
        For(AggregateResult res:[SELECT COUNT(id) id,SUM(Total_Child__c) total, ParentId par FROM  Account WHERE ParentId IN:acccidSet GROUP BY ParentId]){
            system.debug('res:::::::::::15'+res);
            Account acc = new Account();
            if((Decimal)res.get('total')!=NULL){
            acc.Total_Child__c = (Decimal)res.get('total')+(Decimal)res.get('id');
            system.debug('acc.Total_Child__c:::::19::::'+acc.Total_Child__c);
            }else{
                acc.Total_Child__c = (Decimal)res.get('id');
                system.debug('acc.Total_Child__c:::21:::::'+acc.Total_Child__c);
            }
            acc.id = (ID)res.get('par');
            system.debug('acc.id:::::25:::'+acc.id);
            AccMap.put(acc.id,acc);
           System.debug('AccMap.values()::::27:::::'+AccMap.values());
          }
     
        if(!AccMap.isEmpty()){
           update AccMap.values();
           
        }
    }
   Public static void UpdateAmountNewDelete(List<Account> accList){
        Set<ID> acccidSet = new Set<Id>();
       
        Map<id,Account> AccMap = new Map<id,Account>();
        For(Account acc: accList){
            if(acc.ParentId!=NULL){
                AcccidSet.add(acc.ParentId);
                System.debug('AcccidSet'+AcccidSet);
            }
            System.debug('accList'+accList);
        }
        if(AcccidSet.size()>0){
            List<Account> accparent=new List<Account>([select id,parentid,Total_Child__c from Account where id in:AcccidSet]);
            system.debug('accparent :'+accparent);
            integer nco=[select count() from account where parentid in :AcccidSet];
            system.debug('nco  :'+nco);
            for(Account ac:accparent){
                ac.Total_Child__c=nco;
            }
            update accparent;
        }
       
       
    }
   
}
=======================================================
trigger NumberOfChildCount on Account (after insert,after update,after delete) {
    if(trigger.isinsert && trigger.isafter){
        if(RecursiveTriggerHandler.issecondTime){
            RecursiveTriggerHandler.issecondTime= false;
            AccountTriggerHnadler.insertAmount(trigger.new);
        }
    }
    if(trigger.isupdate && trigger.isafter){
        if(RecursiveTriggerHandler.isFirstTime){
            RecursiveTriggerHandler.isFirstTime= false;
            AccountTriggerHnadler.insertAmount(trigger.new);
            AccountTriggerHnadler.insertAmount(trigger.old);
        }
    }
    if(trigger.isdelete && trigger.isafter){
        if(RecursiveTriggerHandler.isThirdTime){
            RecursiveTriggerHandler.isThirdTime= false;
            AccountTriggerHnadler.insertAmount(trigger.old);
        }
    }
}
============================================================
public class RecursiveTriggerHandler{
    public static Boolean isFirstTime = true;
    public static Boolean issecondTime = true;
    public static Boolean isThirdTime = true;
}

ReplyReply allForward
  • April 06, 2020
  • Like
  • 0
in lightning component how to enable popup in iframe
  • March 09, 2020
  • Like
  • 0
how ot write below component contoller and helpr for lighting button in component please help me

<button class="slds-button slds-button_neutral" >
                                    <lightning:icon class="slds-button__icon slds-button__icon_left" iconName="utility:refresh" size="x-small" alternativeText="Refresh" />
                                        Refresh
                                    </button>
  • February 28, 2020
  • Like
  • 0
when page is loading how to put image in place of spinner anybody worked could you please share lightnig component and how to use this component into another component

<aura:component implements="flexipage:availableForAllPageTypes" access="global">
    <aura:attribute type="Integer" name="Logos"/>
    <aura:attribute name="width" type="Integer" default="32" />
    <aura:attribute name="height" type="Integer" default="32" />
    <aura:attribute name="showimage" type="Boolean" default ="false"/>
    <aura:handler event="aura:waiting" action="{!c.showimages}"/>
    <aura:if isTrue="{v.showimage}"> 
    <div aura:id="showimageId" class="slds-spinner_container">
         <div class="slds-spinner--brand  slds-spinner slds-spinner--large slds-is-relative" role="alert">
         <span class="slds-assistive-text">Loading</span>
         <div class="slds-spinner__dot-a"></div>
         <div class="slds-spinner__dot-b"></div>
       </div>
       </div>
    </aura:if>
    <aura:handler name="init" align="center" value="{!this}" action="{!c.doInit}"/>
    <div class="logo cVGA_Loadingimage" data-aura-rendered-by="6:0" data-aura-class="cVGA_Loadingimage" style="
   height: 100vh;
   position: relative;
">
        <img src="/resource/1528440018000/vwlogo" data-aura-rendered-by="7:0" style="
   position: absolute;
   /* margin: auto; */
   left: 40%;
   right: -40%;
   top: 40%;
   bottom: -40%;
">
        </img>
    </div>
    </aura:component>
  • February 13, 2020
  • Like
  • 0
 <ui:InputTextArea value="{!mon.MonthDescription}" class="vw_Plan_blu_bodr" aura:id = "Testdes" disabled="{!v.isDisabled == false}" />
                            
                           
 <ui:InputText value="{!mon.MonthDescription}" class="vw_Plan_blu_bodr" aura:id = "Testdes1" disabled="{!v.isDisabled == True}" />
                            
  • February 07, 2020
  • Like
  • 0
i have create a survey  for external users with out login they are going to complete that survey ,now i am scenario is i need t o post that link in facebook unfortunately it is not working could you please help me on this scenario
  • August 07, 2019
  • Like
  • 0
Hi team ,
Could you please help me linkedin integration with examples and class ,

need to integrate linkedin and salesforce integration
  • July 26, 2019
  • Like
  • 0
need to write mulitple error messages below trigger for multiple fields
Note:suppose if enter name it is throwing error as duplicate for next i am entering email also error message need to display as duplicate same as like phone also

trigger AvoidDuplicate on Contact (before insert)
{    
    
    set<string> newNameSet = new set<string>();
    
    set<string> newEmailSet = new set<string>();
    set<string> newPhoneSet = new set<string>();
    set<string> dbNameSet = new set<string>();
    
    set<string> dbEmailSet = new set<string>();
    set<string> dbPhoneSet = new set<string>();
    
    for(Contact con : trigger.new){
        
        newNameSet.add(con.LastName);
        
        newEmailSet.add(con.Email);
        newPhoneSet.add(con.Phone);
        
    }
    
    List<contact> bcon = [select id, LastName,Phone, email from contact where email IN: newEmailSet OR LastName IN: newNameSet OR Phone IN: newPhoneSet];
   for(Contact dbcon:Trigger.new)
    {
        
        dbNameSet.add(dbcon.LastName);
        
        dbEmailSet.add(dbcon.Email);
        dbPhoneSet.add(dbcon.Phone);
    }
    
    for(contact con1 : trigger.new){        
        if(dbNameSet.contains(con1.LastName) && dbEmailSet.Contains(con1.Email) && dbPhoneSet.Contains(con1.Phone))
        {
            con1.addError('You are inserting Duplicate LastName');
            con2.addError('You are inserting Duplicate Email');
            con3.addError('You are inserting Duplicate Phone');
        }
        
        
    }
    
}
  • June 27, 2019
  • Like
  • 0
hi team ,
Below error message when i am deplpoyiong total copy from my system .
Error: Invalid Data.  Review all error messages below to correct your data. Apex trigger AvoidDuplicate caused an unexpected exception, contact your administrator: AvoidDuplicate: execution of BeforeInsert caused by: System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Contact.Phone: Trigger.AvoidDuplicate: line 27, column 1
  • June 26, 2019
  • Like
  • 0
when i am running below vf page code i am getting error message ,in apex class i am getting response but i am not able to insert values dynamically into the object in class line no 21 it's throing an error
note:Argument cannot be null.
An unexpected error has occurred. Your development organization has been notified.
class:
global class SampleReport {
    public String body{set;get;}
    public list<integer> mylist{set;get;}
    public List<ReportFields> consolewrapperlist{get;set;}
   
    public  SampleReport(){                        
             
        Httprequest req=new Httprequest();
        HttpResponse res = new HttpResponse();
        Http http = new Http();
        string url='https://canvasjs.com/data/gallery/javascript/daily-sales-data.json';
        req.setEndpoint(url);      
        req.setHeader('Content-type','application/json');           
        req.setMethod('GET');
        res = http.send(req);
        system.debug('=========res>>>'+res);
        consolewrapperlist=new List<ReportFields>();
        if(res.getstatusCode() == 200 && res.getbody() != null){
            string body=res.getbody().replaceAll('\n','').replaceAll('\r','');
            system.debug('==========>>>body....>'+body);
            System.JSONParser jp=json.createParser(res.getbody());
            system.debug('==.>>>jp'+jp);
 
            while (jp.nextToken() != null) {
              
                // find the stock part of the response
                if (jp.getCurrentToken() == JSONToken.START_OBJECT) {
                    // parse the stock response and form the response for this controller
                    ReportFields responseObject = (ReportFields)jp.readValueAs(ReportFields.class);
                    Daily_sales_Data__c sd=new Daily_sales_Data__c();
                    sd.date__c=Date.valueOf(responseObject.dates);
                    sd.units__c=Integer.valueOf(responseObject.units);
                    insert sd;                   
                    system.debug('Hello There ' +sd);
                    // return the serialized response
                    //return JSON.serialize(new PackagedReturnItem(returnItems));
                      consolewrapperlist.add(responseObject);
                    system.debug('Hello There ' +consolewrapperlist);
                }
            }
            
               
           
        }else{
            ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Data not find');
           ApexPages.addMessage(myMsg);
        }
       
       
    }
    public class ReportFields
    {
        public String dates;
        public string units;
         public ReportFields(String dates, String units) {
            this.dates = dates;
            this.units = units;
        }
      
      
    }
}
Vf page:
<apex:page controller="SampleReport">
    <apex:form >
        <apex:pageBlock >
          
           
            <apex:pageBlockTable value="{!consolewrapperlist}" var="wrap" width="100%">
               
               
                <apex:column headerValue="date" value="{!wrap.rdate}"/>
                <apex:column headerValue="units" value="{!wrap.runits}"/>
               
               
               
            </apex:pageBlockTable>
           
        </apex:pageBlock>
    </apex:form>
   
</apex:page>
                
  • June 01, 2019
  • Like
  • 0
i have one object name is Reportconfig(this is my custom object name:Reportconfig) in that below  object field i am mentioned after hting that url json need to save
Report Name
Report Source Url
RID
public class reportcon{
    public String apiKey {set;get;}
    public String jsonResult{Set;get;}
    public void getReport(){
        Map<String,reportconfig__c> myMap=reportconfig.getAll();
        reportconfig__c ws=myMap.get('Report Name');
        String url='https://canvasjs.com/data/gallery/javascript/daily-sales-data.json';
        Http p=new Http();
        HttpRequest request =new HttpRequest();
        request.setEndPoint(url);
        request.setMethod('GET');
        HttpResponse response=p.send(request);
        System.debug('====>>'+response);
        jsonResult=response.getBody();
    }
}
 
  • May 23, 2019
  • Like
  • 0
 <ui:InputTextArea value="{!mon.MonthDescription}" class="vw_Plan_blu_bodr" aura:id = "Testdes" disabled="{!v.isDisabled == false}" />
                            
                           
 <ui:InputText value="{!mon.MonthDescription}" class="vw_Plan_blu_bodr" aura:id = "Testdes1" disabled="{!v.isDisabled == True}" />
                            
  • February 07, 2020
  • Like
  • 0
need to write mulitple error messages below trigger for multiple fields
Note:suppose if enter name it is throwing error as duplicate for next i am entering email also error message need to display as duplicate same as like phone also

trigger AvoidDuplicate on Contact (before insert)
{    
    
    set<string> newNameSet = new set<string>();
    
    set<string> newEmailSet = new set<string>();
    set<string> newPhoneSet = new set<string>();
    set<string> dbNameSet = new set<string>();
    
    set<string> dbEmailSet = new set<string>();
    set<string> dbPhoneSet = new set<string>();
    
    for(Contact con : trigger.new){
        
        newNameSet.add(con.LastName);
        
        newEmailSet.add(con.Email);
        newPhoneSet.add(con.Phone);
        
    }
    
    List<contact> bcon = [select id, LastName,Phone, email from contact where email IN: newEmailSet OR LastName IN: newNameSet OR Phone IN: newPhoneSet];
   for(Contact dbcon:Trigger.new)
    {
        
        dbNameSet.add(dbcon.LastName);
        
        dbEmailSet.add(dbcon.Email);
        dbPhoneSet.add(dbcon.Phone);
    }
    
    for(contact con1 : trigger.new){        
        if(dbNameSet.contains(con1.LastName) && dbEmailSet.Contains(con1.Email) && dbPhoneSet.Contains(con1.Phone))
        {
            con1.addError('You are inserting Duplicate LastName');
            con2.addError('You are inserting Duplicate Email');
            con3.addError('You are inserting Duplicate Phone');
        }
        
        
    }
    
}
  • June 27, 2019
  • Like
  • 0
when i am running below vf page code i am getting error message ,in apex class i am getting response but i am not able to insert values dynamically into the object in class line no 21 it's throing an error
note:Argument cannot be null.
An unexpected error has occurred. Your development organization has been notified.
class:
global class SampleReport {
    public String body{set;get;}
    public list<integer> mylist{set;get;}
    public List<ReportFields> consolewrapperlist{get;set;}
   
    public  SampleReport(){                        
             
        Httprequest req=new Httprequest();
        HttpResponse res = new HttpResponse();
        Http http = new Http();
        string url='https://canvasjs.com/data/gallery/javascript/daily-sales-data.json';
        req.setEndpoint(url);      
        req.setHeader('Content-type','application/json');           
        req.setMethod('GET');
        res = http.send(req);
        system.debug('=========res>>>'+res);
        consolewrapperlist=new List<ReportFields>();
        if(res.getstatusCode() == 200 && res.getbody() != null){
            string body=res.getbody().replaceAll('\n','').replaceAll('\r','');
            system.debug('==========>>>body....>'+body);
            System.JSONParser jp=json.createParser(res.getbody());
            system.debug('==.>>>jp'+jp);
 
            while (jp.nextToken() != null) {
              
                // find the stock part of the response
                if (jp.getCurrentToken() == JSONToken.START_OBJECT) {
                    // parse the stock response and form the response for this controller
                    ReportFields responseObject = (ReportFields)jp.readValueAs(ReportFields.class);
                    Daily_sales_Data__c sd=new Daily_sales_Data__c();
                    sd.date__c=Date.valueOf(responseObject.dates);
                    sd.units__c=Integer.valueOf(responseObject.units);
                    insert sd;                   
                    system.debug('Hello There ' +sd);
                    // return the serialized response
                    //return JSON.serialize(new PackagedReturnItem(returnItems));
                      consolewrapperlist.add(responseObject);
                    system.debug('Hello There ' +consolewrapperlist);
                }
            }
            
               
           
        }else{
            ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Data not find');
           ApexPages.addMessage(myMsg);
        }
       
       
    }
    public class ReportFields
    {
        public String dates;
        public string units;
         public ReportFields(String dates, String units) {
            this.dates = dates;
            this.units = units;
        }
      
      
    }
}
Vf page:
<apex:page controller="SampleReport">
    <apex:form >
        <apex:pageBlock >
          
           
            <apex:pageBlockTable value="{!consolewrapperlist}" var="wrap" width="100%">
               
               
                <apex:column headerValue="date" value="{!wrap.rdate}"/>
                <apex:column headerValue="units" value="{!wrap.runits}"/>
               
               
               
            </apex:pageBlockTable>
           
        </apex:pageBlock>
    </apex:form>
   
</apex:page>
                
  • June 01, 2019
  • Like
  • 0