• abi1.2911902284080376E12
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 4
    Replies

Product Approval

 

 

Product :

0-234032-02

 

 

Product :

0-230057-01

 

 

Here, im using a wrapper class to display the list of products from the opportunity and using a checkbox when the user selects the products and clicks "approve" button i update a field with the value "Approved"  in the product record.

The problem im facing here is, when i select all the products and click "approve" the update works. And for the first time if i select one product of the two products and click "approve", the update works. But the next time if i select the other product and click "approve" the button is not getting fired. While the second time i click the same "approve" consecutively it works. Im not able to figure out whats the reason for this behaviour.


Please suggest what to do.

 

Code:

 

public class cls_Approve
{
    public cls_Approve(ApexPages.StandardController controller)
    {
        opp = (opportunity)controller.getRecord();        
        oppLineItem = [Select PricebookEntry.Product2.id,PricebookEntry.Product2.name , PricebookEntry.Product2.HD_Product_Approval__c from OpportunityLineItem where OpportunityId  =: opp.id];
    }
    public class wrapProduct
    {
        public boolean chkProduct{get;set;}       
        public string wrapLineItemName{get;set;}
        public string wrapLineItemId{get;set;}
        public Opportunity wrapOpp{get;set;}      
        public wrapProduct(Opportunity op)
        {
            wrapOpp =  op;
        }
    }       
    public List<wrapProduct> getwrapProdList()
    {
        queryResults = new List<wrapProduct>();
        for(opportunityLineItem oli : oppLineItem)
        {
            wrapProduct wpObj = new wrapProduct(opp);          
            if(oli.PricebookEntry.Product2.name != null)
            {                
                wpObj.wrapLineItemName = oli.PricebookEntry.Product2.name;
            }
            wpObj.wrapLineItemId = oli.PricebookEntry.Product2.id;                            
            queryResults.add(wpObj);
        }        
        return queryResults;            
    }                 
    public List<string> updateProdId = new List<string>();
    public List<product2> updateProd2 = new List<product2>();
    public List<product2> pList = new List<product2>();   
    public pagereference approveProduct()
    {                                         
        for(wrapProduct wpList:queryResults)
        {                                         
            if(wpList.chkProduct == true)
            {
                updateProdId.add(wpList.wrapLineItemId);                         
            }                       
        }        
        if(updateProdId.size() >0)
        {                        
            pList = [select HD_Product_Approval__c from  product2 where id in: updateProdId];           
        }
        for(product2 p2:pList)
        {            
            p2.HD_Product_Approval__c = 'Approved';
            updateProd2.add(p2);                                       
        }       
        update updateProd2;          
        return null;
    }        
}

 

VisualForce Page:

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

<apex:page id="Page1" standardController="opportunity" extensions="cls_Approve">
    <apex:form id="form1">        
        <b>Product Approval</b>
        <apex:repeat value="{!wrapProdList}" var="oli">             
            <table border='1'>
                <tr>
                    <td align="center">
                        <apex:inputCheckbox id="chkProd" value="{!oli.chkProduct}" disabled="{!oli.disableChkProduct}"/>     
                    </td>
                    <td align="center">
                        <b> Product : </b>     
                    </td>
                    <td>
                        <apex:outputText value="{!oli.wrapLineItemName}"/>
                    </td>                        
                </tr>              
            </table>
        </apex:repeat>
        <apex:commandButton value="approve" action="{!approveProduct}" rerender="table1" disabled="{!fnProdApprove}"/>      
    </apex:form>   
</apex:page>

In the contract object i have added a custom look up field for products. This lookup shows all the products in the organisation. But i want to filter the display in such a way that only the Opportunity Line Items(opportunity products) of the opportunity associated with this contract to appear in the lookup dialog from which the user can choose.

 

Any suggestions??

Based on a product quantity im displaying product name and price in a datatable. Now at the end of each product list i need a row that should display the sum of the product price. How do i generate this list?

Im using a datatable to display the product name and price. i want to insert  the "total" and "overall total" rows dynamically. please suggest how to do this..

 

Product Name

Total Price

Acer- Liquid Car Charger

7

Acer- Liquid Car Charger

7

Acer- Liquid Car Charger

7

Acer- Liquid Car Charger

7

Acer- Liquid Car Charger

7

Total

35

Acer Neo Touch Leather Case

10

Acer Neo Touch Leather Case

10

Acer Neo Touch Leather Case

10

Acer Neo Touch Leather Case

10

Acer Neo Touch Leather Case

10

total

50

Overall total

85

I have created a visualforce page that displays a datatable with columns containing values  from various standard objects. I have used a wrapper class for this and populate it in  the datatable using a list of the type wrapper class. Now in the visualforce page i wanna save each row data to a custom object. How do i do this?  

In visual force page i use a standard controller contract and the extension as wrapper class.

Product Approval

 

 

Product :

0-234032-02

 

 

Product :

0-230057-01

 

 

Here, im using a wrapper class to display the list of products from the opportunity and using a checkbox when the user selects the products and clicks "approve" button i update a field with the value "Approved"  in the product record.

The problem im facing here is, when i select all the products and click "approve" the update works. And for the first time if i select one product of the two products and click "approve", the update works. But the next time if i select the other product and click "approve" the button is not getting fired. While the second time i click the same "approve" consecutively it works. Im not able to figure out whats the reason for this behaviour.


Please suggest what to do.

 

Code:

 

public class cls_Approve
{
    public cls_Approve(ApexPages.StandardController controller)
    {
        opp = (opportunity)controller.getRecord();        
        oppLineItem = [Select PricebookEntry.Product2.id,PricebookEntry.Product2.name , PricebookEntry.Product2.HD_Product_Approval__c from OpportunityLineItem where OpportunityId  =: opp.id];
    }
    public class wrapProduct
    {
        public boolean chkProduct{get;set;}       
        public string wrapLineItemName{get;set;}
        public string wrapLineItemId{get;set;}
        public Opportunity wrapOpp{get;set;}      
        public wrapProduct(Opportunity op)
        {
            wrapOpp =  op;
        }
    }       
    public List<wrapProduct> getwrapProdList()
    {
        queryResults = new List<wrapProduct>();
        for(opportunityLineItem oli : oppLineItem)
        {
            wrapProduct wpObj = new wrapProduct(opp);          
            if(oli.PricebookEntry.Product2.name != null)
            {                
                wpObj.wrapLineItemName = oli.PricebookEntry.Product2.name;
            }
            wpObj.wrapLineItemId = oli.PricebookEntry.Product2.id;                            
            queryResults.add(wpObj);
        }        
        return queryResults;            
    }                 
    public List<string> updateProdId = new List<string>();
    public List<product2> updateProd2 = new List<product2>();
    public List<product2> pList = new List<product2>();   
    public pagereference approveProduct()
    {                                         
        for(wrapProduct wpList:queryResults)
        {                                         
            if(wpList.chkProduct == true)
            {
                updateProdId.add(wpList.wrapLineItemId);                         
            }                       
        }        
        if(updateProdId.size() >0)
        {                        
            pList = [select HD_Product_Approval__c from  product2 where id in: updateProdId];           
        }
        for(product2 p2:pList)
        {            
            p2.HD_Product_Approval__c = 'Approved';
            updateProd2.add(p2);                                       
        }       
        update updateProd2;          
        return null;
    }        
}

 

VisualForce Page:

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

<apex:page id="Page1" standardController="opportunity" extensions="cls_Approve">
    <apex:form id="form1">        
        <b>Product Approval</b>
        <apex:repeat value="{!wrapProdList}" var="oli">             
            <table border='1'>
                <tr>
                    <td align="center">
                        <apex:inputCheckbox id="chkProd" value="{!oli.chkProduct}" disabled="{!oli.disableChkProduct}"/>     
                    </td>
                    <td align="center">
                        <b> Product : </b>     
                    </td>
                    <td>
                        <apex:outputText value="{!oli.wrapLineItemName}"/>
                    </td>                        
                </tr>              
            </table>
        </apex:repeat>
        <apex:commandButton value="approve" action="{!approveProduct}" rerender="table1" disabled="{!fnProdApprove}"/>      
    </apex:form>   
</apex:page>

Based on a product quantity im displaying product name and price in a datatable. Now at the end of each product list i need a row that should display the sum of the product price. How do i generate this list?

Im using a datatable to display the product name and price. i want to insert  the "total" and "overall total" rows dynamically. please suggest how to do this..

 

Product Name

Total Price

Acer- Liquid Car Charger

7

Acer- Liquid Car Charger

7

Acer- Liquid Car Charger

7

Acer- Liquid Car Charger

7

Acer- Liquid Car Charger

7

Total

35

Acer Neo Touch Leather Case

10

Acer Neo Touch Leather Case

10

Acer Neo Touch Leather Case

10

Acer Neo Touch Leather Case

10

Acer Neo Touch Leather Case

10

total

50

Overall total

85

I have created a visualforce page that displays a datatable with columns containing values  from various standard objects. I have used a wrapper class for this and populate it in  the datatable using a list of the type wrapper class. Now in the visualforce page i wanna save each row data to a custom object. How do i do this?  

In visual force page i use a standard controller contract and the extension as wrapper class.