• Amol Solanki
  • NEWBIE
  • 25 Points
  • Member since 2014

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 8
    Replies
I need to overwrite and add some logic when loading the standard opportunity page. Therefore I need to overwrite apex logic. If this is possible what is the method that should be overwrite?
Hi Friends ,

I need a approach to fetch 10 mostly/frequently hit records in an object.has anyone implemented this.if so please revert back.
NOTE: I just need a approach or if anyone has the implemented code then it would be like cherry on top of the cake.
Thanks for reading this post and helping me out.
  
Help us in parsing this nested List -Webservice?


{"ProductionOrder":"O000039","statusType":"download",
   "folder1":[{"subFolder1":[{"FileVar":{"Name":"Age-Christoffer Lundeby_extra-large.jpeg","currentext":".jpeg","Dirfilename":"/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/Age-Christoffer Lundeby_extra-large_t.jpg","location":"a0eN0000000tELT","filepreviewurl":"cifs://121.240.144.237:445/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/Age-Christoffer Lundeby_extra-large.jpeg","filethumburl":"/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/Age-Christoffer Lundeby_extra-large_t.jpg","orderid":"O000039","filestatus":"TBI","fileurl":"cifs://121.240.144.237:445/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/Age-Christoffer Lundeby_extra-large.jpeg"}},
       {"FileVar":{"Name":"Aqua.jpg","currentext":".jpg","Dirfilename":"/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/Aqua_t.jpg","location":"a0eN0000000tELT","filepreviewurl":"cifs://121.240.144.237:445/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/Aqua.jpg","filethumburl":"/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/Aqua_t.jpg","orderid":"O000039","filestatus":"TBI","fileurl":"cifs://121.240.144.237:445/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/Aqua.jpg"}},
       {"FileVar":{"Name":"Blinds.jpg","currentext":".jpg","Dirfilename":"/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/Blinds_t.jpg","location":"a0eN0000000tELT","filepreviewurl":"cifs://121.240.144.237:445/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/Blinds.jpg","filethumburl":"/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/Blinds_t.jpg","orderid":"O000039","filestatus":"TBI","fileurl":"cifs://121.240.144.237:445/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/Blinds.jpg"}},
       {"FileVar":{"Name":"heart_wings.eps","currentext":".eps","Dirfilename":"/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/heart_wings_t.jpg","location":"a0eN0000000tELT","filepreviewurl":"cifs://121.240.144.237:445/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/heart_wings.eps","filethumburl":"/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/heart_wings_t.jpg","orderid":"O000039","filestatus":"TBI","fileurl":"cifs://121.240.144.237:445/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/heart_wings.eps"}},
        {"subFolder2":[{"FileVar":{"Name":"Blinds.jpg","currentext":".jpg","Dirfilename":"/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/subFolder/Blinds_t.jpg","location":"a0eN0000000tELT","filepreviewurl":"cifs://121.240.144.237:445/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/subFolder/Blinds.jpg","filethumburl":"/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/subFolder/Blinds_t.jpg","orderid":"O000039","filestatus":"TBI","fileurl":"cifs://121.240.144.237:445/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/subFolder/Blinds.jpg"}},
                      {"FileVar":{"Name":"heart_wings.eps","currentext":".eps","Dirfilename":"/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/subFolder/heart_wings_t.jpg","location":"a0eN0000000tELT","filepreviewurl":"cifs://121.240.144.237:445/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/subFolder/heart_wings.eps","filethumburl":"/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/subFolder/heart_wings_t.jpg","orderid":"O000039","filestatus":"TBI","fileurl":"cifs://121.240.144.237:445/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/subFolder/heart_wings.eps"}
       }]
     }]
   }]


'{"ProductionOrder":"O000039","statusType":"download", "folder1":[{"subFolder1":[{"FileVar":{"Name":"Age-Christoffer Lundeby_extra-large.jpeg","currentext":".jpeg","Dirfilename":"/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/Age-Christoffer Lundeby_extra-large_t.jpg","location":"a0eN0000000tELT","filepreviewurl":"cifs://121.240.144.237:445/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/Age-Christoffer Lundeby_extra-large.jpeg","filethumburl":"/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/Age-Christoffer Lundeby_extra-large_t.jpg","orderid":"O000039","filestatus":"TBI","fileurl":"cifs://121.240.144.237:445/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/Age-Christoffer Lundeby_extra-large.jpeg"}}, {"FileVar":{"Name":"Aqua.jpg","currentext":".jpg","Dirfilename":"/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/Aqua_t.jpg","location":"a0eN0000000tELT","filepreviewurl":"cifs://121.240.144.237:445/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/Aqua.jpg","filethumburl":"/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/Aqua_t.jpg","orderid":"O000039","filestatus":"TBI","fileurl":"cifs://121.240.144.237:445/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/Aqua.jpg"}}, {"FileVar":{"Name":"Blinds.jpg","currentext":".jpg","Dirfilename":"/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/Blinds_t.jpg","location":"a0eN0000000tELT","filepreviewurl":"cifs://121.240.144.237:445/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/Blinds.jpg","filethumburl":"/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/Blinds_t.jpg","orderid":"O000039","filestatus":"TBI","fileurl":"cifs://121.240.144.237:445/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/Blinds.jpg"}}, {"FileVar":{"Name":"heart_wings.eps","currentext":".eps","Dirfilename":"/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/heart_wings_t.jpg","location":"a0eN0000000tELT","filepreviewurl":"cifs://121.240.144.237:445/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/heart_wings.eps","filethumburl":"/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/heart_wings_t.jpg","orderid":"O000039","filestatus":"TBI","fileurl":"cifs://121.240.144.237:445/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/heart_wings.eps"}}, {"subFolder2":[{"FileVar":{"Name":"Blinds.jpg","currentext":".jpg","Dirfilename":"/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/subFolder/Blinds_t.jpg","location":"a0eN0000000tELT","filepreviewurl":"cifs://121.240.144.237:445/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/subFolder/Blinds.jpg","filethumburl":"/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/subFolder/Blinds_t.jpg","orderid":"O000039","filestatus":"TBI","fileurl":"cifs://121.240.144.237:445/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/subFolder/Blinds.jpg"}}, {"FileVar":{"Name":"heart_wings.eps","currentext":".eps","Dirfilename":"/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/subFolder/heart_wings_t.jpg","location":"a0eN0000000tELT","filepreviewurl":"cifs://121.240.144.237:445/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/subFolder/heart_wings.eps","filethumburl":"/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/subFolder/heart_wings_t.jpg","orderid":"O000039","filestatus":"TBI","fileurl":"cifs://121.240.144.237:445/share/JavaDev/Input/20151124/O000039/JAPAN/20151030/subFolder/heart_wings.eps"} }] }]   }]';
Hi

I have created a class for uploading file.but when  i am uplaoding any file more than 135KB its showing Maximum view state size limit (135KB) exceeded .how to overcome this..
public class Confirmation {
    public Order__c Order{get;set;}
    public  Attachment attachment {get;set;}
    public boolean showC1RecordType {get;set;}
    public boolean showC2RecordType {get;set;} 
    
    private Id c1RecordTypeId; 
    private Id c2RecordTypeId;
    
    public Confirmation(ApexPages.StandardController controller) {
        c1RecordTypeId = Schema.SObjectType.Order__c.getRecordTypeInfosByName().get('C1').getRecordTypeId();
        c2RecordTypeId = Schema.SObjectType.Order__c.getRecordTypeInfosByName().get('C2').getRecordTypeId();
        
        Order = new Order__c();
        Order = (Order__c)controller.getRecord();
        
        String isButtonClicked = Apexpages.currentPage().getParameters().get('setDefaultValues');
        if(isButtonClicked == 'true'){
            setDefaultValues();
        }
        
        showC1RecordType = false;
        showC2RecordType = false;
        attachment = new Attachment();
        
        
        if(Order.RecordTypeId == c1RecordTypeId){
            showC1RecordType = true;
            showC2RecordType = false;
        }
        else if(Order.RecordTypeId == c2RecordTypeId){
            showC1RecordType = false;
            showC2RecordType = true;
        }
        
    }
    
     public void setDefaultValues(){
        String quoteId = Apexpages.currentPage().getParameters().get('quoteId');
        Quote__c quote = [Select o.id, o.name, o.Quantity_formula__c, o.Opportunity_Product_Detail__r.Opportunity__c,
                    o.Opportunity__c, o.Record_type_name__c,o.Company_Name__c,Opportunity_Product_Detail__r.Opportunity__r.Account__c from Quote__c o WHERE O.id=:quoteId];
        //system.assert(false,quote);     
        Order.Opportunity__c = quote.Opportunity_Product_Detail__r.Opportunity__c;
        Order.Quote__c = quote.id;
       Order.Company__c = quote.Opportunity_Product_Detail__r.Opportunity__r.Account__c;
        
        if(quote.Record_type_name__c == 'C1'){
           Order.RecordTypeId = c1RecordTypeId;
        }
        else {
            Order.RecordTypeId = c2RecordTypeId;
        }
    }
    public PageReference save(){
        if(attachment.Body == null){
            Apexpages.addMessage(new Apexpages.Message(Apexpages.Severity.ERROR, ' record'));
            return null;
        }
        else{
            try{
                insert Order;
                
                attachment.OwnerId = UserInfo.getUserId();
                attachment.ParentId = Order.id;
                insert attachment;
                
                return new PageReference('/'+Order.id);
            }
            catch(DMLException e){
                ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,e.getMessage()));
                return null;
            }
        }
    }
}

 
/*********************************************************************************************************************
* Name               : CPQ_CTRL_CheckOpenOpportunities                                                               *
* Description        : The class performs following functionality:                                                   *
*                      - This class is controller class for CPQ_CTRL_CheckOpenOpportunities_VFP_Opp VisualForce page.*                     
* Created Date       : 04-Dec-2015                                                                                   *
* Created By         : Accenture                                                                                     *
* Last Modified Date :                                                                                               *
* Last Modified By   :                                                                                               *
* -------------------------------------------------------------------------------------------------------------------*
* VERSION     AUTHOR      DATE                                                                                       *
*   1.0 -    Accenture   04-Dec-2015                                                                                 *
**********************************************************************************************************************/
public with sharing class CPQ_CTRL_CheckOpenOpportunities {
    public String accId{get;set;}
    public Opportunity opportunity{get;set;}
    public List<Opportunity> oppList{get;set;}
    public Boolean showAccountPgBlock {set;get;}
    public Boolean showOppListPgBlock {set;get;}    
    public Pagereference pgref;
    public String customLabelRecordTypeOpp = Label.lbl_Opportunity_New_Record;   
    
    /***********************************************************************************************
    * @Description : Controller                                                                    *
    *                This controller class fetches accountId & CustomLabel.                        *
    * @Params      : ApexPages.StandardController                                                  *
    * @Return      :                                                                               *    
    ***********************************************************************************************/
    public CPQ_CTRL_CheckOpenOpportunities(ApexPages.StandardController controller) {
        accId = apexpages.currentpage().getparameters().get('accid');
        opportunity= new Opportunity();
    }

 // Query on Record Type of Opportunity to fetch the RecordTypeId having name 'New'
    RecordType rt = [SELECT Id FROM RecordType where DeveloperName = : customLabelRecordTypeOpp AND sObjectType = 'Opportunity' limit 1];
    
    /****************************************************************************
     * @Description :This method check for the open Opportunities associated to the account .*
     * @Params      : none                                                    *
     * @Return      : pgref                                                  *    
     ****************************************************************************/

    public pagereference checkStageBeforeInsert() {    
        CPQ_UTIL_CommonMethod uHelper = new CPQ_UTIL_CommonMethod();
        oppList = uHelper.checkOpenOpportunities(accId);
    
        pgref = new pagereference('/006/e?retURL=%2F'+ accId +'&accid='+ accId + '&RecordType=' + rt.Id + '&ent=Opportunity');
        pgref.setRedirect(true);
        pgref.getParameters().put('nooverride', '0');

        if (accId != null) {
            showAccountPgBlock = false;
            showOppListPgBlock = true;
            if (oppList.size() > 0){
                return null;
            }else {   
                return pgref;
            }
        } 
        else{    
            showAccountPgBlock = true;
            showOppListPgBlock = false;
            return null;   
        }
    }
    
    /*********************************************************************************************
    *@Description : This method redirect the user to the Origin page *
    *@Params      : AccountId                                                                        *
    *@Return      : pgref                                                             *    
    *********************************************************************************************/  
    public pagereference cancelOpportunity() {    
      if(accId == null){   
          pgref = new pagereference('/006/o');        
      }
      else{
          pgref = new pagereference('/'+accId );    
      }      
        pgref.setRedirect(true);
        pgref.getParameters().put('nooverride', '0'); 
        return pgref;   
    }
    
    
   /**********************************************************************************************
    *@Description : This method returns the List of Open Opportunities                           *
    *@Params      : AccountId                                                                    *
    *@Return      : List of Open Opportunities                                                   *    
    *********************************************************************************************/     
    public pagereference opportunitiesOnAccount() {
        showOppListPgBlock = true;
        CPQ_UTIL_CommonMethod uHelper = new CPQ_UTIL_CommonMethod();
        oppList = uHelper.checkOpenOpportunities(opportunity.AccountId);
        if(oppList.size()==0){
            pgref = new pagereference('/006/e?retURL=%2F006%2Fo&accid=' + opportunity.AccountId + '&RecordType='+rt.Id+'&ent=Opportunity');
            pgref.setRedirect(true);
            pgref.getParameters().put('nooverride', '0');  
            return pgref;            
        }
        else{          
            return null;
        }
    }
    
    
   /*********************************************************************************************
    *@Description : This method is used to continue and create new Opportunity.                                       *
    *@Params      : void                                                                         *
    *@Return      : pgref                                                             *    
    *********************************************************************************************/    
    public pagereference newOpportunity(){   
        if (accId == null) {
            pgref = new pagereference('/006/e?retURL=%2F006%2Fo&accid=' + opportunity.AccountId + '&RecordType='+rt.Id+'&ent=Opportunity');
            pgref.setRedirect(true);
            pgref.getParameters().put('nooverride', '0');
            return pgref;
        } 
        else {
            return pgref;
        }    
    }

// End of Class.

// Test class for this...
@isTest
private class CPQ_CTRL_CheckOpenOpportunitiesTest {
    static testMethod void validateOpenOpportunitiesClass() 
    {

        Account testAccount= TestDataUtil.createAccount();
       /* Test.startTest();
       // Database.DeleteResult result = Database.insert(testAccount, false);
        Test.stopTest();
        */ 
        
        RecordType rt = [SELECT Id FROM RecordType where DeveloperName ='CPQ_New' AND sObjectType = 'Opportunity' limit 1];  
    
        ApexPages.StandardController sc = new ApexPages.StandardController(testAccount);
        CPQ_CTRL_CheckOpenOpportunities testAccPlan = new CPQ_CTRL_CheckOpenOpportunities(sc);
        
        PageReference pageRef = Page.CPQ_CTRL_CheckOpenOpportunities_VFP_Opp;
        pageRef.getParameters().put('accId', testAccount.Id);
        pageRef.getParameters().put('RecordType', rt.Id);
        Test.setCurrentPage(pageRef);
        
        testAccPlan.checkStageBeforeInsert();
        testAccPlan.cancelOpportunity();
        testAccPlan.opportunitiesOnAccount();
        testAccPlan.newOpportunity();        
    }
}
I need to overwrite and add some logic when loading the standard opportunity page. Therefore I need to overwrite apex logic. If this is possible what is the method that should be overwrite?

Hi,

 

following are the code requirements:

1. If value entered in product name is not present in Products, then it should enable Save button.

2. If value entered in product name is present in Products, then it should display all the contents in a table.

 

VF Code:

<apex:page StandardController="Product__c" extensions="ExistingController"  >
   <apex:form id="fm" >
   <apex:actionFunction name="invoke" action="{!search}" reRender="pb"/>

       <apex:pageBlock id="pb" title="Products" mode="edit" >
           <apex:pageBlockSection id="pbs" title="Search/Create a Product record" columns="2">
               <apex:inputField id="ifname" value="{!Product__c.name}"  />
               <apex:inputField value="{!Product__c.Description__c}" />
               <apex:inputField value="{!Product__c.Total_Inventory__c}"  />
               <apex:inputField value="{!Product__c.Price__c}" />
               <apex:inputField value="{!Product__c.Stock_Quantity__c}" />
           </apex:pageBlockSection>
               <apex:pageBlockButtons >
               <apex:commandButton value="reset"  action="{!Reset}"/>
               <apex:commandButton value="Save" action="{!Save}" rendered="{!flag}"/>
               <apex:commandButton value="Search" OnClick="nameNull()"/>
           </apex:pageBlockButtons>
          
           <apex:pageBlockTable id="pbt" var="pb" value="{!prodRecordList}">
               <apex:column value="{!pb.Name}" />
               <apex:column value="{!pb.Description__c}"/>
               <apex:column value="{!pb.Total_Inventory__c}"/>
               <apex:column value="{!pb.Price__c}"/>
               <apex:column value="{!pb.Stock_Quantity__c}"/>
           </apex:pageBlockTable>
           </apex:pageBlock>
      
      
   </apex:form>
   <script>
       function nameNull(){
           var text= document.getElementById("{!$Component.fm.pb.pbs.ifname}").value;
           if(text == '')
           {alert('Please enter value in Product Name field');
           }
           else
                {           invoke();
                                                   }        
                                           }
   </script>
</apex:page>

 

 

Controller Code:

 

public class ExistingController {

   public string nameStr{ get; private set; }
   Public List<product__c> prodRecordList {get; set;}
   Public product__c prod {get; set;}
   public boolean flag {get; set;}
  
   public ExistingController(ApexPages.StandardController stdController) {
       this.prod= (product__c)stdController.getRecord();
   }
  
   public pageReference search () {

       prodRecordList =  [SELECT id, Name, Description__c, Total_Inventory__c, Price__c, Stock_Quantity__c from product__c where name=:prod.name];
       System.debug('@@prodRecordList'+prodRecordList);
       if(prodRecordList.size()==0 )
      
           flag = true;
           return null;
   }
   public pageReference Reset() {

       PageReference newpage = new PageReference(System.currentPageReference().getURL());
       newpage.setRedirect(true);
       return newpage;  
          }
      
  public pageReference Save()  {
  INSERT prod;
  pageReference newpage = new PageReference('/apex/recordsaved');
  return newpage;
  }
}

 

When calling directly it works, but when called from Javascript action function it does not. Please help.

Hi.

 

I am getting the following error on a vforce page I am trying to create

 

Save error: Unknown property 'VisualforceArrayList.Description'

 

and I have no idea why.  I have treid using a list, and not using a list.  I have tried everything I can think of, but nothing seems to help.    Any help is much appreciate so thank you in advance.

 

Here is the relevant parts  of the controller class

 

public with sharing class Controller_QuotePage {
   public Quote qt {get; set;}
   public List<QuoteLineItem> theLineItems {get; set;}
   public Controller_QuotePage(ApexPages.StandardController controller) 
   {
       Id quoteID = ((Quote) controller.getRecord()).Id;
       loadQuote(quoteId);
       loadQuoteLineItems(quoteId);
    }
 	
    public List<QuoteLineItem> getLineItems(){
		 
		 return theLineItems;
    }
	

   private void loadQuote(String quoteId) {
        this.qt = [Select Id,  Site_Address__c,       
                  CreatedDate,ExpirationDate FROM Quote where    
                  Id=:quoteId];  
      
   }
    
   private void loadQuoteLineItems(String quoteId) {

       this.theLineItems = [SELECT Id, Description, Quantity, UnitPrice,
	     	            TotalPrice,Total_MRC__c,   Total_NRC__c    
                             FROM QuoteLineItem WHERE QuoteId =:   
                             quoteId];	
	   		
    }


}

 

 

And here is the relevant parts of the visualforce page

 

 

<apex:page standardController="Quote" renderAs="pdf"
	extensions="Controller_QuotePage">

<apex:dataTable value="{!LineItems}" var="LineItems">
<apex:column headerValue="Line Item" value="{!LineItems.Description}"/>
</apex:dataTable>


</apex:page>

 

 

 

  HI

I was trying to call a custom javascript function on click which inturn calls the action function I would like to know if I am doing it right. its not going into my controller function.
This is what I want to do
 
function save_clicked() // custom function
{
// logic(this part works)
  saveOrder();// call to the action function
}         

<apex:actionFunction name="saveOrder" action="{!SaveProgramOrderAndItems}" />
       <apex:pageBlockButtons location="bottom">
          
  <apex:commandButton value="Save and Create Order" onclick="save_clicked"/>