• Vrushali Mali 4
  • NEWBIE
  • 20 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 4
    Replies
Hello people,

i Have Account Name for eg MEDITERRANEAN SHIPPING LTD CO and i want to display MEDSHI  that is first 3 letters of the first word and 3 letters of the second word. And it should apply for all account.
Hi all, I have a requirement custom lead conversion process here my lead and Opportunity is custom object please help me out in this particular area
trigger CreateOrder on Order__c (before insert,After Insert) {
        Set<Id> OppId = new Set<Id>();
        Set<Id> OffId = new Set<Id>();
        Map<Id,Offer__c> MapOff = new Map<Id,Offer__c>();
        List<Product_Detail_for_Order__c> ordforProd = new List<Product_Detail_for_Order__c>();
        Map<Id,List<Product_Detail_for_Offer__c>> offforProd = new Map<Id,List<Product_Detail_for_Offer__c>>();
    
    if(Trigger.isbefore){
        for(Order__c ord : Trigger.new){
            if(!String.isBlank(ord.Opportunity__c))
            {
                OppId.add(ord.Opportunity__c);
            }
            else if(!String.isBlank(ord.Offer__c))
            {
                OffId.add(ord.Offer__c);
            }
        }
        if(!OppId.isEmpty())
        {
            for(Offer__c off : [Select Id,Name,Opportunity__c,Partner__c from Offer__c where Opportunity__c =:OppId ORDER BY CreatedDate ASC NULLS FIRST])
            {
                MapOff.put(off.Opportunity__c, off);
            }
        }
        if(!OffId.isEmpty())
        {
            for(Offer__c ofo : [Select Id,Name,Opportunity__c,Partner__c from Offer__c where Id =: OffId] ){
                MapOff.put(ofo.Id,ofo);
            }
        }
        for(Order__c order : Trigger.new)
        {
            if(!String.isBlank(order.Opportunity__c))
            {
                Offer__c ofs = MapOff.get(order.Opportunity__c);
                order.Partner_Name__c = ofs.Partner__c;
                order.Opportunity__c = ofs.Opportunity__c;
                order.Id = ofs.Id;
             
            }
            else if(!String.isBlank(order.Offer__c))
            {
                Offer__c ofs = MapOff.get(order.Offer__c);
                order.Partner_Name__c = ofs.Partner__c;
                order.Opportunity__c = ofs.Opportunity__c;
                
            }
        }
    }
    
    if(Trigger.isAfter)
    {
        for(Order__c order : Trigger.new)
        {
            if(!String.isBlank(order.Offer__c)){
                OffId.add(order.Offer__c);
            }
        }
        for(Product_Detail_for_Offer__c ensp  : [Select Id,Currency__c,Customer_Drawing_Number__c,Customer_Item_No_Drawing_No1__c,Model_No__c,Enquiry_Product_Backend__c,Product_Description__c,Offer__c,Offer_Type__c,Opportunity__c,Partner_Drawing_Number__c,Partner_Item_Material_Code__c,Partner_Item_No_Drawing_No__c,Parter_Model_Code__c,Product__c,Product_code_Description__c,Quantity__c,Rate_Contract__c,Regret__c,Total_Amount__c,Unit_Price__c from Product_Detail_for_Offer__c where Id =:OffId])
        {
            List<Product_Detail_for_Offer__c> eis = new List<Product_Detail_for_Offer__c>();
            if(offforProd.get(ensp.Offer__c) != null)
                eis = offforProd.get(ensp.Offer__c);
                eis.add(ensp);
                offforProd.put(ensp.Offer__c, eis);
            
        }
            for(Order__c ord : Trigger.new){
                
                List<Product_Detail_for_Offer__c> eis = new List<Product_Detail_for_Offer__c>();
                eis = offforProd.get(ord.Offer__c);
                System.debug('******eis*****'+eis);
                for(Product_Detail_for_Offer__c off : eis){
                    
                    Product_Detail_for_Order__c ordp = new Product_Detail_for_Order__c();
                    ordp.Opportunity__c = off.Opportunity__c;
                    ordp.Customer_Item_Material_Code__c = off.Customer_Item_No_Drawing_No1__c;
                    ordp.Customer_Drawing_Number__c = off.Customer_Drawing_Number__c;
                    ordp.Product__c = off.Product__c;
                    ordp.Quantity__c = off.Quantity__c;
                    ordp.Unit_Price__c = off.Unit_Price__c;
                    ordp.Order__c = ord.Id;
                    
                    ordforProd.add(ordp);
                }
            }
            System.debug('******ordforProd******'+ordforProd);
            Insert ordforProd;
        }
    }
Hi,
 This is my trigger : can any one help me where i am wrong.
trigger ClosedOpportunityTrigger on Opportunity (after insert, after update) {
    
    //List<Task> tasklst = [select id from Task limit 200]; 
    for(Opportunity opp : Trigger.new){
        
        //for(Opportunity op : opplst){
        if(opp.StageName == 'Closed Won'){
        
          
           Task t = new Task();
           t.WhatId = opp.id;
           t.Subject = 'Follow Up Test Task';
           t.Ownerid = opp.Ownerid;
           t.ActivityDate = system.today();

           insert t;
           system.debug('+++++++t++++++'+t);
        
       
    
    }
    }

}
public class MultiAdd1
{
    
    //will hold the account records to be saved
    public List<Account>lstAcct  = new List<Account>();
    
    //list of the inner class
    public List<innerClass> lstInner 
    {get;set;}
    
    //will indicate the row to be deleted
    public String selectedRowIndex
    {get;set;}  
    
    //no. of rows added/records in the inner class list
    public Integer count = 1;
    //{get;set;}
    
    
    ////save the records by adding the elements in the inner class list to lstAcct,return to the same page
    public PageReference Save()
    {
        PageReference pr = new PageReference('/apex/MultiAdd');
        
        for(Integer j = 0;j<lstInner.size();j++)
        {
            lstAcct.add(lstInner[j].acct);
        } 
        insert lstAcct;
        pr.setRedirect(True);
        return pr;
    }
        
    //add one more row
    public void Add()
    {   
        count = count+1;
        addMore();      
    }
    
    /*Begin addMore*/
    public void addMore()
    {
        //call to the iner class constructor
        innerClass objInnerClass = new innerClass(count);
        
        //add the record to the inner class list
        lstInner.add(objInnerClass);    
        system.debug('lstInner---->'+lstInner);            
    }/* end addMore*/
    
    /* begin delete */
    public void Del()
    {
        system.debug('selected row index---->'+selectedRowIndex);
        lstInner.remove(Integer.valueOf(selectedRowIndex)-1);
        count = count - 1;
        
    }/*End del*/
    
    
    
    /*Constructor*/
    public MultiAdd1(ApexPages.StandardController ctlr)
    {
    
        lstInner = new List<innerClass>();
        addMore();
        selectedRowIndex = '0';
        
    }/*End Constructor*/
        


    /*Inner Class*/
    public class innerClass
    {       
        /*recCount acts as a index for a row. This will be helpful to identify the row to be deleted */
        public String recCount
        {get;set;}
        
        
        public Account acct 
        {get;set;}
        
        /*Inner Class Constructor*/
        public innerClass(Integer intCount)
        {
            recCount = String.valueOf(intCount);        
            
            /*create a new account*/
            acct = new Account();
            
        }/*End Inner class Constructor*/    
    }/*End inner Class*/
}/*End Class*/
"oppclass Compile Error: The method object <Constructor>(ApexPages.StandardController) is referenced by Visualforce Page (InvoicePDF) in salesforce.com."
Here is my class:

public class oppclass {
  public list<opportunity>opplist{get;set;}
   public ID opportunityid{get;set;}

    public oppclass() {
    
        opplist = new list<opportunity>();
        opplist = [select Name from opportunity];
        
    }

}
I want number format in Indian rupees. Can any one suggest me how to do using <outputText value> Indian Rupee format is like eg. 1,23,000.00
Hi all, I have a requirement custom lead conversion process here my lead and Opportunity is custom object please help me out in this particular area
Hi,
 This is my trigger : can any one help me where i am wrong.
trigger ClosedOpportunityTrigger on Opportunity (after insert, after update) {
    
    //List<Task> tasklst = [select id from Task limit 200]; 
    for(Opportunity opp : Trigger.new){
        
        //for(Opportunity op : opplst){
        if(opp.StageName == 'Closed Won'){
        
          
           Task t = new Task();
           t.WhatId = opp.id;
           t.Subject = 'Follow Up Test Task';
           t.Ownerid = opp.Ownerid;
           t.ActivityDate = system.today();

           insert t;
           system.debug('+++++++t++++++'+t);
        
       
    
    }
    }

}
"oppclass Compile Error: The method object <Constructor>(ApexPages.StandardController) is referenced by Visualforce Page (InvoicePDF) in salesforce.com."
Here is my class:

public class oppclass {
  public list<opportunity>opplist{get;set;}
   public ID opportunityid{get;set;}

    public oppclass() {
    
        opplist = new list<opportunity>();
        opplist = [select Name from opportunity];
        
    }

}
Hi Developers,

Can anyone help me on this issue, I have a Child object that has a Lookup to Parent. I wrote the below apex class and the trigger on child, such that the count of Child records should be shown on each Parent record. I have a number field on the Parent which should be update as per the Trigger.

It works fine except in one scenario, it does not consider the existing Child records on the Parent, hence it shows incorrect count on the Parent record. It works perfect if I add the new Child records. I heard that Batch Apex can resolve this issue, I am not sure how Batch Apex is related here to resolve the isssue. Can I get some guidance here to proceed further.


Any help on this is much appreciated.
Thank you.

Apex Class:

public class ChildCountHelper{
    
    //List<Parent__c> parentList = [select id, child_count__c, (select id from child__r) from Parent__c where id in :parentIDSet];
    
    public List<ID> conList= new List<ID>();
    
    public static void handleBeforeInsert(List<Child__c> childList){
        Set<ID> parentIDSet = new Set<ID>();
        
        for(Child__c childRec: childList){
     
            parentIDSet.add(childRec.Parent__c);
            
        }
        
        Map<ID, Parent__c> parentMap = new map<ID, parent__c>([select id, child_count__c from Parent__c where id in :parentIDSet]);
        for(Child__c childRec: childList){
            if(parentMap.get(childRec.Parent__c).child_count__c == null){
                parentMap.get(childRec.Parent__c).child_count__c = 0;
            }
            parentMap.get(childRec.Parent__c).child_count__c ++;
        }
        update parentMap.values();
    }
    
    public static void handleBeforeUpdate(List<Child__c> newChildList, List<Child__c> oldChildList){
        Set<ID> parentIDSet = new Set<ID>();
        Map<ID, ID> oldChildMap = new Map<ID, ID>();
        
        for(Child__c childRec: newChildList){
            parentIDSet.add(childRec.Parent__c);
        }
        
        for(Child__c childRec: oldChildList){
            parentIDSet.add(childRec.Parent__c);
            oldChildMap.put(childRec.Id, childRec.Parent__c);
        }
        
        Map<ID, Parent__c> parentMap = new map<ID, parent__c>([select id, child_count__c from Parent__c where id in :parentIDSet]);
        for(Child__c childRec: newChildList)
       {
        /*if(ChildRec.Parent__c!=null){  */
            if(parentMap.get(childRec.Parent__c).child_count__c == null){
                parentMap.get(childRec.Parent__c).child_count__c = 0;
            }
           // }
            if(childRec.Parent__c != oldChildMap.get(childRec.id)){
                if(oldChildMap.get(childRec.id) == null && childRec.Parent__c != null){
                    parentMap.get(childRec.Parent__c).child_count__c ++;
                }else if(oldChildMap.get(childRec.id) != null && childRec.Parent__c == null){
                    parentMap.get(oldChildMap.get(childRec.id)).child_count__c --;
                }else if(oldChildMap.get(childRec.id) != null && childRec.Parent__c != null){
                    parentMap.get(oldChildMap.get(childRec.id)).child_count__c --;
                    parentMap.get(childRec.Parent__c).child_count__c ++;
                }
            }
            
        }
        update parentMap.values();
    }
    
    public static void handleBeforeDelete(List<Child__c> childList){
        Set<ID> parentIDSet = new Set<ID>();
        for(Child__c childRec: childList){
            parentIDSet.add(childRec.Parent__c);
        }
        
        Map<ID, Parent__c> parentMap = new map<ID, parent__c>([select id, child_count__c from Parent__c where id in :parentIDSet]);
        for(Child__c childRec: childList){
            if(parentMap.get(childRec.Parent__c).child_count__c == null){
                parentMap.get(childRec.Parent__c).child_count__c = 0;
            }
            parentMap.get(childRec.Parent__c).child_count__c --;
        }
        update parentMap.values();
    }
    
    public static void handleBeforeUnDelete(List<Child__c> childList){
        Set<ID> parentIDSet = new Set<ID>();
        for(Child__c childRec: childList){
            parentIDSet.add(childRec.Parent__c);
        }
        
        Map<ID, Parent__c> parentMap = new map<ID, parent__c>([select id, child_count__c from Parent__c where id in :parentIDSet]);
        for(Child__c childRec: childList){
            if(parentMap.get(childRec.Parent__c).child_count__c == null){
                parentMap.get(childRec.Parent__c).child_count__c = 0;
            }
            parentMap.get(childRec.Parent__c).child_count__c ++;
        }
        update parentMap.values();
    }

}




Trigger:


trigger ChildTrigger on Child__c (before insert, after update, after delete, after undelete) {
    if (Trigger.isInsert) {
        ChildCountHelper.handleBeforeInsert((List<Child__c>)Trigger.NEW);
    }else if (Trigger.isUpdate) {
        ChildCountHelper.handleBeforeUpdate((List<Child__c>)Trigger.NEW, (List<Child__c>)Trigger.OLD);
    }else if (Trigger.isDelete) {
        ChildCountHelper.handleBeforeDelete((List<Child__c>)Trigger.OLD);
    }else if (Trigger.isUndelete) {
        ChildCountHelper.handleBeforeUnDelete((List<Child__c>)Trigger.NEW);
    }
}