• Pravin
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 4
    Replies
Hi All,

I am trying to display Product2 record based on product family and on selection of particular family want to prepopulate few fields like product family opportunity etc to a custom object edit detail page. i did some programing but getting the following error

Map key null not found in map
Error is in expression '{!map_productfamily[allpr]}' in component <apex:pageBlockTable> in page qualification

My code
VF
<apex:page id="p" standardcontroller="Qualification__c" extensions="Qualification" standardStylesheets="true" tabStyle="Qualification__c">

  <apex:form id="frm">
   
  <apex:pageblock id="allprods" title="Available Products" rendered="{!bool_nshow}">
               <apex:pageblocktable id="allprods" value="{!map_productfamily}" var="allpr">
                   <!-- <apex:column headervalue="Select Family">                   
                       <apex:actionsupport action="{!selectprodfam}" event="onclick" rerender="allpro,allprods,frm" status="reload"> 
                        <input type="radio" />                   
                            <apex:param name="prodid" value="{!allpro.Id}">
                        </apex:param></apex:actionsupport>                           
                    </apex:column>   -->
                    <apex:repeat value="{!map_productfamily[allpr]}" var="allpro" >
                    <apex:column headervalue="Product Family" rowspan="">
                        <apex:outputfield value="{!allpro.Product_Family__c}">
                    </apex:outputfield></apex:column>  
                   
                    <apex:column headervalue="Segment">
                        <apex:outputfield value="{!allpro.Segment__c}">
                    </apex:outputfield></apex:column> 
                    <apex:column headervalue="Sub Segment">
                        <apex:outputfield value="{!allpro.Sub_Segment__c}">
                    </apex:outputfield></apex:column> 
                   
                    <apex:column headervalue="Active">
                        <apex:outputfield value="{!allpro.IsActive}">
                    </apex:outputfield></apex:column>
                    </apex:repeat>
     
                </apex:pageblocktable>
               
    <apex:actionStatus id="reload" style="align:center;" >
        <apex:facet name="start">
            <apex:image value="/img/loading.gif" title="Processing..."/>
        </apex:facet>
        <apex:facet name="stop"></apex:facet>
    </apex:actionStatus>
                       
</apex:pageblock>

<apex:pageblock id="selectprods" title="Products available Under selected Family" rendered="{!bool_show}">
               <apex:pageblocktable id="allprods" value="{!list_pp}" var="allpro">
                   <!-- <apex:column headervalue="Select">                   
                       <apex:actionsupport action="{!selectprod}" event="onclick" rerender="allpro" status="reload"> 
                        <input type="radio" />                   
                            <apex:param name="prodid" value="{!allpro.Id}">
                        </apex:param></apex:actionsupport>                           
                    </apex:column>   -->
                   
                    <apex:column headervalue="Product Name">
                        <apex:outputfield value="{!allpro.Name}">
                    </apex:outputfield></apex:column>  
               
                    <apex:column headervalue="Segment">
                        <apex:outputfield value="{!allpro.Segment__c}">
                    </apex:outputfield></apex:column> 
                    <apex:column headervalue="Sub Segment">
                        <apex:outputfield value="{!allpro.Sub_Segment__c}">
                    </apex:outputfield></apex:column> 
                   
                    <apex:column headervalue="Active">
                        <apex:outputfield value="{!allpro.IsActive}">
                    </apex:outputfield></apex:column>
                   
    
                </apex:pageblocktable>
            
   
     <apex:actionStatus id="disablebtn">
     <apex:facet name="stop">    
           <apex:commandButton value="Back" onClick="BackActionFunc();" status="disablebtn" disabled="false" reRender="disablebtn"/>  
     </apex:facet>    
     <apex:facet name="start">
      <apex:commandButton value="Processing..." onClick="BackActionFunc();" status="disablebtn" disabled="true" reRender="disablebtn"/>                </apex:facet>
    </apex:actionStatus>
  
   
    <apex:actionStatus id="reload" style="align:center;" >
        <apex:facet name="start">
            <apex:image value="/img/loading.gif" title="Processing..."/>
        </apex:facet>
        <apex:facet name="stop"></apex:facet>
    </apex:actionStatus>
    
       
                     
</apex:pageblock>
<apex:actionFunction name="BackActionFunc" action="{!setBoolean}" rerender="frm,allprods,selectprods" />

</apex:form>
</apex:page>




Apex:

/************************************************************************************
Opportunity Product field mapping during new qualification creation
Created By:Pravin
Created Date:10/06/2014
*************************************************************************************/
global class Qualification{
    private list<OpportunityLineItem> list_opplineitem;
    public list<Product2> list_product{get;set;}
    public boolean bool_show{get;set;}
    public boolean bool_nshow{get;set;}
    public list<Product2> list_pp{get;set;}
    public map<string,list<Product2>> map_productfamily=new map<string,list<Product2>>();
    public map<string,list<Product2>> getmap_productfamily(){
        return map_productfamily;
    }
    string str_oppname;
    Id opidd;
    set<Id>    set_prodid=new set<Id>();
    public Qualification(ApexPages.StandardController controller) {
    bool_show=false;
    bool_nshow=true;
    system.debug('>>contbool_nshow>>>>'+bool_nshow);
    list_opplineitem= [SELECT Id,Product2Id FROM OpportunityLineItem
                   WHERE OpportunityId = :ApexPages.currentPage().getParameters().get('oppid')];
                   system.debug('????'+list_opplineitem);
                  
    str_oppname=[select id,name from opportunity where id  = :ApexPages.currentPage().getParameters().get('oppid')].Name;           
    opidd= ApexPages.currentPage().getParameters().get('oppid');             
   
    /*******************************************************************/
        for(OpportunityLineItem ol: list_opplineitem){
            set_prodid.add(ol.Product2Id);
        }
        list_product=[select Id,Name,Product2.Family,Product_Family__r.Name,Product_Family__c,IsActive,Segment__c,Sub_Segment__c from Product2 where id IN:set_prodid/* order by Product2.Family ASC*/];
        system.debug('>>>'+list_product);
        for(product2 pp:list_product){
        if(pp.Product_Family__r.Name!=null && pp.Product_Family__r.Name!=''){
            if(map_productfamily.containskey((string)pp.Product_Family__r.Name)){
                list<Product2> temp_p=map_productfamily.get(pp.Product_Family__r.Name);
                temp_p.add(pp);
                map_productfamily.remove(pp.Product_Family__r.Name);
                map_productfamily.put((string)pp.Product_Family__r.Name,temp_p);
            }
            else{
               
                map_productfamily.put((string)pp.Product_Family__r.Name,new list<product2>{pp});
            }
        }
       
        }
    
    /*********************************************************************/
   
    //if(list_opplineitem.size()>0)
    //findproductfamily(list_opplineitem);
   
    }
   
    public void findproductfamily(list<OpportunityLineItem> list_litem){
       
        for(OpportunityLineItem ol: list_litem){
            set_prodid.add(ol.Product2Id);
        }
        list_product=[select Id,Name,Product2.Family,Product_Family__c,IsActive,Segment__c,Sub_Segment__c from Product2 where id IN:set_prodid/* order by Product2.Family ASC*/];
        system.debug('>>>'+list_product);
       
    }

   Public pagereference selectprod(){
        system.debug('>>>>>>');
        string fmlyname;
        string segname;
        string subsegname;
        Id fmlyid;
        Id segid;
        Id subsegid;
        String selproductid = System.currentPagereference().getParameters().get('prodid');
        system.debug('>>>>>>'+selproductid);
        list<Product2> pp=[select Product2.Family,Product_Family__c,Product_Family__r.Name,Sub_Segment__c,Sub_Segment__r.Name,Segment__c,Segment__r.Name,IsActive from Product2 where Id=:selproductid];
        if(PP.size()>0){
            fmlyid=pp[0].Product_Family__c;
            fmlyname=pp[0].Product_Family__r.Name;
            segid=pp[0].Segment__c;
            segname=pp[0].segment__r.Name;
            subsegid=pp[0].Sub_Segment__c;
            subsegname=pp[0].sub_segment__r.Name;
        }
        PageReference newocp = new PageReference('/a0X/e?CF'+system.Label.Id_of_Opportunity_field_on_Qualification+'='+str_oppname+'&CF'+system.Label.Id_of_Opportunity_field_on_Qualification+'_lkid='+opidd+'&CF'+system.Label.Id_of_Product_Family_field_on_Qualification+'='+fmlyname+'&CF'+system.Label.Id_of_Product_Family_field_on_Qualification+'_lkid='+fmlyid+'&CF'+system.Label.Id_of_Segment_field_on_Qualification+'='+segname+'&CF'+system.Label.Id_of_Segment_field_on_Qualification+'_lkid='+segid+'&CF'+system.Label.Id_of_Sub_Segment_field_on_Qualification+'='+subsegname+'&CF'+system.Label.Id_of_Sub_Segment_field_on_Qualification+'_lkid='+subsegid+'&retURL=/apex/Qualification?oppid='+ApexPages.currentPage().getParameters().get('oppid')+'');
        newocp.setRedirect(true);
        return newocp;
   }
  
    Public void selectprodfam(){
       
        bool_show=true;
        bool_nshow=false;
       
        system.debug('>>fambool_nshow>>>>'+bool_nshow);
        String selproductid = System.currentPagereference().getParameters().get('prodid');
        Product2 pp=[select Product2.Family,Product_Family__c,Product_Family__r.Name,Sub_Segment__c,Sub_Segment__r.Name,Segment__c,Segment__r.Name from Product2 where Id=:selproductid limit 1];
       list_pp=[select Name,Product2.Family,Product_Family__c,Product_Family__r.Name,Sub_Segment__c,Sub_Segment__r.Name,Segment__c,Segment__r.Name,IsActive from Product2 where Product_Family__c=:pp.Product_Family__c And id IN:set_prodid];
      
   }
   
   public Pagereference setBoolean(){
       system.debug('>>setbool_nshow>>>>'+bool_nshow);
       bool_nshow=true;
        bool_show=false;
        PageReference returl = new PageReference('/apex/Qualification?oppid='+opidd);
        returl.setRedirect(true);
        return returl;
   }           
 
  webservice static string findLineItem(Id oppid){
  list<Opportunitylineitem> list_opplineitem=[select id from Opportunitylineitem where OpportunityId =: oppid];
  system.debug('>>>>>>'+list_opplineitem);
  if(list_opplineitem.size()>0){
  return 'true';
  }
  else
  return 'false';
 
  }
 
 

}

looking for a quick reply on this.
  • October 10, 2014
  • Like
  • 0
Hi Team,

I am working on batch job which is operating on lots of records. I need to create opportunity sharing based on account sharing.I have written a batch job which is woking on  account records 1000 as batch size. First i am taking all opportunity records linked to those accounts and passing the id of account and opportunity to a different normal apex class. In the for loop i am  iterating on all the linked opportunity records (more than 10000 opp records linked to 1000 account records).When i am trying to create opp share records for those opp records and upserting them getting the below error
                                     "too many dml rows 10001"
Please tell me the  solution for this( instead of reducing the batch size).

My code snippet
Batch Job Execute method

global void execute(Database.BatchableContext BC, List<Sobject> scope){
        List<Opportunity> opptyList = (List<Opportunity>)scope;
       // Set<ID> oppIds = new Set<ID>():
         Set<ID> accountIds = new Set<ID>();
        Map<ID,Set<ID>> acctOppIDs = new Map<ID,Set<ID>>();
        for(Opportunity oppty : opptyList) {
            if(oppty.Sold_To_Account__c != null){
             //   oppIds.add(oppty.id);
                accountIDs.add(oppty.Sold_To_Account__c);
                if(acctOppIDs.get(oppty.Sold_To_Account__c) == null) {
                    acctOppIDs.put(oppty.Sold_To_Account__c, new Set<ID>());
                }
                acctOppIDs.get(oppty.Sold_To_Account__c).add(oppty.id);
            }
            //Update Opportunities Flag
          oppty.SoldToChanged__c = false;
         
        }
        System.SavePoint pSavepoint = null;
        if(accountIDs.size() >0) {
            try {
             pSavepoint = Database.setSavepoint(); 
             ShareOpportunitiesUtil.shareOpptys(accountIDs, acctOppIDs);
             //Update Opportunities Flag
             upsert opptyList;
            }catch(Exception ex) {
                errorMsg +=ex.getMessage()+'\n';
              Database.rollback(pSavepoint);
            }
        }
    }

My normal Class
public without sharing class ShareOpportunitiesUtil {
    public static void shareOpptys(Set<ID> accountIDs, Map<ID,Set<ID>> acctOppIDs) {
       
        List<OpportunityShare> oppSharesList = new List<OpportunityShare> ();
        for(AccountShare accShare :[Select a.UserOrGroupId, a.RowCause, a.OpportunityAccessLevel,
                                     a.AccountAccessLevel, a.AccountID
                                     From AccountShare a
                                     where accountID in :accountIDs]) {
      OpportunityShare oppShare = null;
      for (String oppId :acctOppIDs.get(accShare.AccountID)) {
          oppShare = new OpportunityShare();
          oppShare.OpportunityId = oppId;
          oppShare.UserOrGroupId = accShare.UserOrGroupId;
          oppShare.OpportunityAccessLevel = 'Edit'; //HA changed to Edit accShare.AccountAccessLevel;
          oppSharesList.add(oppShare);
      }
    }
    try {
        Database.upsert(oppSharesList,false);
    }catch(Exception ex) {
        System.debug('Exception occured');
        throw ex;
    }
    }
}

Appreciate your help.

Thanks
Pravin
  • April 18, 2014
  • Like
  • 1

Hi 

 

I am implementing Email To Case functionality ,but have some trouble with Email related list on case record.

 

Listing below the things i have implemented:

1.Once i am sending a mail to email service address a case is getting created.

2.If mail contains any attachment it is coming under Email related list with mail body content.

3.I can send a mail using SendMail button to the requester who raised the case.

 

Facing the trouble in below scenario:

4.Once a requester is replying back to that email the email is coming to my outllok email as it is configured with my salesforce instance.It is not coming in the Email related list of case record which is my desired functionality.

 

Can anyone suggest me how to achieve it.

 

Thanks

Pravin

  • December 09, 2013
  • Like
  • 0

Hi,

 

I am using standard approval process with several steps(each approval process having total 8 steps) based on user country criteria.Those approval process are getting called through trigger .

 

Like if the record gets updated trigger getting fired and based on criteria crossponding approval process gets called.

First approval is called and after some field update again the next approval is called through trigger,the entire functionality is working like that.

 

But some time(1 out of 50-60 times) after the field update of the first approval next approval is auto rejected. But if i am again working with the same record i am not able to replicate it again.

 

i have not added such criteria that if the criteria will not match for approval it should rejected or approved .

 

Any suggestion will be much appreciated.

 

Thanks,

  • February 05, 2013
  • Like
  • 0

Hi

 

I have written a schedular class its working fine in my  own login.salesforce.com instance but not working in my sandbox.After deleting the schedule job also its its showing that its running but not making the desired changes.

I thought some other schedular using this class.For clearing the doubt i have created the new class new schedualr class and created the schedule job that will schedule the  class  after 1-2 hr .Before the class get schedule i have deleted the schdule job. and try to modified the code its showing that the message"Schedulable class has jobs pending or in progress at line 1 column 8". Its also not allowing to delete the code. Is it a issue with sandbox.Any help will be greatfull.

 

Regards

pravin...

  • September 25, 2012
  • Like
  • 0

Hi

I am using apex:PageBlockTable which has huge records and  i have business requirement  to freez the header portion of PageBlock Table so that the header  will fix and data will move.

 

Any help will be greatful.

 

Thanks

Pravin

  • September 06, 2012
  • Like
  • 0

Hi

 

I am trying to fixed the header using <apex:pageBlockTable headerClass="#header-row{position:fixed;top:0;left:0; }">

using its "headerClass" attribute but its not worging .


 If any input will be much appreciate.

 

Thakns

Pravin.

 

 

 

 

  • September 04, 2012
  • Like
  • 0

Hi

 

I am using pagination to show 500 records with 75 records/page in visualforce page. I have to make some fields inline edit and for that when i am ptting  mode="inlineEdit" in pageblock tag then it makes the entire 500 records with all fields inline edit and also the changes are not getting reflected.

 

Any help will be greatful.

 

Thanks

Pravin...

  • September 04, 2012
  • Like
  • 0

During Export to Excel process, I am trying to export all data to excel sheet by calling a vf page from the exsisting Vf page .

The amount of data is 500-600 (less than 1000). But when i am clicking the button to call the other Vf page its through an error
"Maximum view state size limit (135KB) exceeded. Actual view state size for this page was 174.469KB "

Any help will be very greatfull.

  • September 03, 2012
  • Like
  • 0
Hi Team,

I am working on batch job which is operating on lots of records. I need to create opportunity sharing based on account sharing.I have written a batch job which is woking on  account records 1000 as batch size. First i am taking all opportunity records linked to those accounts and passing the id of account and opportunity to a different normal apex class. In the for loop i am  iterating on all the linked opportunity records (more than 10000 opp records linked to 1000 account records).When i am trying to create opp share records for those opp records and upserting them getting the below error
                                     "too many dml rows 10001"
Please tell me the  solution for this( instead of reducing the batch size).

My code snippet
Batch Job Execute method

global void execute(Database.BatchableContext BC, List<Sobject> scope){
        List<Opportunity> opptyList = (List<Opportunity>)scope;
       // Set<ID> oppIds = new Set<ID>():
         Set<ID> accountIds = new Set<ID>();
        Map<ID,Set<ID>> acctOppIDs = new Map<ID,Set<ID>>();
        for(Opportunity oppty : opptyList) {
            if(oppty.Sold_To_Account__c != null){
             //   oppIds.add(oppty.id);
                accountIDs.add(oppty.Sold_To_Account__c);
                if(acctOppIDs.get(oppty.Sold_To_Account__c) == null) {
                    acctOppIDs.put(oppty.Sold_To_Account__c, new Set<ID>());
                }
                acctOppIDs.get(oppty.Sold_To_Account__c).add(oppty.id);
            }
            //Update Opportunities Flag
          oppty.SoldToChanged__c = false;
         
        }
        System.SavePoint pSavepoint = null;
        if(accountIDs.size() >0) {
            try {
             pSavepoint = Database.setSavepoint(); 
             ShareOpportunitiesUtil.shareOpptys(accountIDs, acctOppIDs);
             //Update Opportunities Flag
             upsert opptyList;
            }catch(Exception ex) {
                errorMsg +=ex.getMessage()+'\n';
              Database.rollback(pSavepoint);
            }
        }
    }

My normal Class
public without sharing class ShareOpportunitiesUtil {
    public static void shareOpptys(Set<ID> accountIDs, Map<ID,Set<ID>> acctOppIDs) {
       
        List<OpportunityShare> oppSharesList = new List<OpportunityShare> ();
        for(AccountShare accShare :[Select a.UserOrGroupId, a.RowCause, a.OpportunityAccessLevel,
                                     a.AccountAccessLevel, a.AccountID
                                     From AccountShare a
                                     where accountID in :accountIDs]) {
      OpportunityShare oppShare = null;
      for (String oppId :acctOppIDs.get(accShare.AccountID)) {
          oppShare = new OpportunityShare();
          oppShare.OpportunityId = oppId;
          oppShare.UserOrGroupId = accShare.UserOrGroupId;
          oppShare.OpportunityAccessLevel = 'Edit'; //HA changed to Edit accShare.AccountAccessLevel;
          oppSharesList.add(oppShare);
      }
    }
    try {
        Database.upsert(oppSharesList,false);
    }catch(Exception ex) {
        System.debug('Exception occured');
        throw ex;
    }
    }
}

Appreciate your help.

Thanks
Pravin
  • April 18, 2014
  • Like
  • 1

Hi,

 

I am using standard approval process with several steps(each approval process having total 8 steps) based on user country criteria.Those approval process are getting called through trigger .

 

Like if the record gets updated trigger getting fired and based on criteria crossponding approval process gets called.

First approval is called and after some field update again the next approval is called through trigger,the entire functionality is working like that.

 

But some time(1 out of 50-60 times) after the field update of the first approval next approval is auto rejected. But if i am again working with the same record i am not able to replicate it again.

 

i have not added such criteria that if the criteria will not match for approval it should rejected or approved .

 

Any suggestion will be much appreciated.

 

Thanks,

  • February 05, 2013
  • Like
  • 0

Hi

 

I am trying to fixed the header using <apex:pageBlockTable headerClass="#header-row{position:fixed;top:0;left:0; }">

using its "headerClass" attribute but its not worging .


 If any input will be much appreciate.

 

Thakns

Pravin.

 

 

 

 

  • September 04, 2012
  • Like
  • 0

During Export to Excel process, I am trying to export all data to excel sheet by calling a vf page from the exsisting Vf page .

The amount of data is 500-600 (less than 1000). But when i am clicking the button to call the other Vf page its through an error
"Maximum view state size limit (135KB) exceeded. Actual view state size for this page was 174.469KB "

Any help will be very greatfull.

  • September 03, 2012
  • Like
  • 0