• shardul singh 23
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
The below code combines two lists as one list and sorts the list.
public with sharing class ProductCostSalesSheet {


    public ProductCostSalesSheet() {
        o = [select id from Opportunity where id =: System.currentpageReference().getParameters().get('oppid')];
        system.debug('*********************000000000:'+ o); 
        oppi = o.id;  
        system.debug('*********************000000001:'+ oppi); 
        
    }

    
    id oppi;
    Public final Opportunity o;
    List<String> prodOption = new List<String>();
    Map<String, String> joinMap = new Map<String, String>();

    public ProductCostSalesSheet(ApexPages.StandardController controller) {
        
        }

      public  List<string> getOppProductOptions(){
      
      prodOption = new List<String>();
      

       for(OpportunityLineItem oli: [select id, Product2.name, unitprice, discount, totalprice, quantity from OpportunityLineItem where OpportunityId =: oppi]){
           joinMap.put(oli.id, oli.id+','+oli.product2.name+','+oli.quantity+','+oli.discount+','+oli.unitprice);
       }
       
       for(Proposal_Option__c p : [select id, Opportunity_Product__c, Description__c,sequence__c,sales_price__c,discount__c,unit_price__c,quantity__c from Proposal_Option__c where Opportunity__c =: oppi]){
           joinMap.put(p.Opportunity_Product__c+p.id, p.Opportunity_Product__c+p.sequence__c+','+p.Description__c+','+p.quantity__c+','+p.discount__c+','+p.unit_price__c);
           system.debug('*********************000000003:'+ joinMap); 
       }
       prodOption = joinMap.values();
      
       prodOption.sort();
    
       return prodOption;
    }

}
The code does the following:
1. Joins mulitple fields into one comma-separated string.
2. Combines two lists into a map, then a list.
3. Sorts the list.
4. returns the list.

How do I now convert the comma-separated string to a list?
 

Hi All,

 

I want to get all fieldnames of a object in apex. How can I do this?

 

For example for User object I want to get all its field names like AboutMe, AccountId , Email etc.

 

Any help on this really appreciated.

 

Regards,

Naren

  • January 18, 2012
  • Like
  • 0