• PreeSFDCDev
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 11
    Replies
Hi,
I am facing issue in sorting the pageblock table.
I am created a VF page where I have created a picklist to show the listview options of my custom object "Project"  using projsetcontroller.getListViewOptions() method. Based on the option selected in list view , I am showing the list of records in pageblock table using projsetcontroller.setFilterId()
Code is working fine till here.
Now if I am trying to sort of any column in the table. It is always returning the record in ASC order. Sort fucntionality seems not working.
Is there anyone who has done this functionality. Please let me know
My requirement is to schedule a Job every 30 minutes. I can do this using two CRON Expresssions (as given below), but I want to see if we can do this in one expression ? Advantage of having one single job is that "if the job take more than 30 minutes to process, second job wont fire". By having two different expressions, they can be running together.

String cronStr1 = '0 00 * * * ?';
String cronStr2 = '0 30 * * * ?';
Hi,
I need that my column header value in a pagebloack table in vf page should be fixed while scrolling and viewing data.
How to do this?

Thanks in Advance!
Hi ,

I would like to implement sorting in VF column header for list views of Opportunity.I have used StandardSetController for this, the getRecords() method working very fine while changing the list views.But list returned from getRecords() is immmutable and i am not able to change or sort while clicking on any column header.Thought of using SOQL queries for each List view and sort using order by clause, but there the problem is for every users' list views may differ.So generating dynamic SOQL according to logged in users list view on Opportunity : if you have any idea in this please help.

Please also share any idea/thought related to sort a vf page by column header for list view controller.

MY Page is :
<apex:page standardController="Opportunity" recordSetVar="opportunities" tabStyle="Opportunity" sidebar="false" extensions="OppRecordSetVarController4" >
    <style>
        div.hideCurrDate span.dateInput span.dateFormat{
           display:none;
        }   
        
    </style> 

    <apex:stylesheet value="{!URLFOR($Resource.Spinner, 'spinner.css')}"/>
    <apex:includeScript value="{!URLFOR($Resource.Spinner, 'jquery.min.js')}"/>
    <apex:includeScript value="{!URLFOR($Resource.Spinner, 'spinner.js')}"/>
    <div class="splashStatus" id="splashDiv">
    <div class="circle"><img src="{!URLFOR($Resource.Spinner, 'spinner.gif')}"/></div>
    <div class="txt">Please Wait. Loading...</div>
    </div>
    <body>  
    <apex:form id="theForm">
        
        <apex:pageBlock id="thePageblock" >
            <apex:pageMessages />           

            <apex:pageBlockButtons location="bottom" id="paginationButtons">
                <apex:commandButton value="First" action="{!doFirst}" disabled="{!!HasPrevious}" />
                &nbsp;&nbsp;
                <apex:commandButton value="Previous" action="{!doPrevious}" disabled="{!!HasPrevious}" />
                &nbsp;&nbsp;
                <apex:commandButton value="Next" action="{!doNext}" disabled="{!!hasnext}" />
                &nbsp;&nbsp;
                <apex:commandButton value="Last" action="{!doLast}" disabled="{!!hasnext}" />
            </apex:pageBlockButtons>
            
            <apex:pageBlockButtons location="top" >                         
            <apex:outputLabel value="Select View:" id="theOutputLabel"/>       
            <apex:actionStatus id="splashStatus" onstart="startSplash();" onstop="endSplash();" />
            
            <apex:selectList value="{!filterId}" size="1">                 
                <apex:actionSupport event="onchange" rerender="thePageblock" status="splashStatus" />
                <apex:selectOptions value="{!listviewoptions}"/>                                      
            </apex:selectList>
            
            <apex:commandButton value="Save" action="{!doSave}"/>
            <apex:commandButton value="Cancel" action="{!doCancel}"/>
            </apex:pageBlockButtons>
            
            <apex:pageBlockTable value="{!opportunities}" var="opp" id="list1" >           

                <td><apex:column headerValue="Account Name">
                <apex:outputLink value="/{!opp.Account.Id}">{!opp.Account.Name}</apex:outputLink>
                </apex:column></td>
                <td><apex:column headerValue="Opportunity Name">
                <apex:facet name="header">
                <apex:commandLink action="{!ViewData}" value="Opportunity Name{!IF(sortExpression=='Name',IF(sortDirection='ASC','▲','▼'),'')}" reRender="thePageblock" >
                    <apex:param value="Name" name="column" assignTo="{!sortExpression}" ></apex:param>
                </apex:commandLink>
                </apex:facet>
                <apex:outputLink value="/{!opp.id}">{!opp.Name}</apex:outputLink>
                </apex:column></td>
                <apex:column headerValue="Stage" >
                <apex:actionRegion >                
                    <apex:inputField value="{!opp.stageName}" style="width:90px">
                        <apex:actionSupport event="onchange" action="{!changeStageName}" reRender="probabilityInput" status="PStatus" />
                        <!-- <apex:param value="{!opp.stageName}" assignTo="{!selectedOppStage}"/> -->
                    </apex:inputfield>                 
                </apex:actionRegion> 
                </apex:column> 
                          
                <td ><apex:column headerValue="P(%)" id="probability"> 
                    <apex:actionStatus startText="Loading.." id="PStatus" />                 
                    <apex:inputField value="{!opp.Probability}" style="text-align:center;width:50px" id="probabilityInput"/>
                </apex:column>
                </td>

                <td><apex:column headerValue="Excl." >
                    <apex:inputField value="{!opp.Exclude_From_Forecast__c}" style="width:30px"/>
                </apex:column></td>
                <td ><apex:column headerValue="W/Amount" >
                    <apex:inputField value="{!opp.ExpectedRevenue}" style="text-align:right;width:60px" />
                </apex:column>
                </td>
                <apex:column headerValue="PO Date">
                <apex:facet name="header">
                <apex:commandLink action="{!ViewData}" value="PO Date{!IF(sortExpression=='PO Date',IF(sortDirection='ASC','▲','▼'),'')}"  reRender="thePageblock">
                    <apex:param value="PO Date" name="column" assignTo="{!sortExpression}" ></apex:param>
                </apex:commandLink>
                </apex:facet>
                <div class="hideCurrDate">
                    <apex:inputField value="{!opp.closeDate}" />
                </div>
                </apex:column>                
     
                <apex:column headerValue="D2Inv">
                    <apex:inputField value="{!opp.Days_to_Invoice__c}" style="text-align:center;width:30px"/>
                </apex:column>
                <apex:column headerValue="Invoice date">
                <div class="hideCurrDate">    
                    <apex:inputField value="{!opp.Invoice_Date__c}" style="width:70px"/>
                </div>    
                </apex:column>
                <apex:column headerValue="Access">
                    <apex:inputField value="{!opp.Access__c}" style="text-align:right;width:60px"/>
                </apex:column> 
                <apex:column headerValue="Video">
                    <apex:inputField value="{!opp.Video__c}" style="text-align:right;width:60px"/>
                </apex:column>   
                <apex:column headerValue="Fire">
                    <apex:inputField value="{!opp.Fire__c}" style="text-align:right;width:60px"/>
                </apex:column> 
                <apex:column headerValue="Intrusion">
                    <apex:inputField value="{!opp.Intrusion__c}" style="text-align:right;width:60px"/>
                </apex:column>   
                <apex:column headerValue="Fiber">
                    <apex:inputField value="{!opp.Fiber__c}" style="text-align:right;width:60px"/>
                </apex:column>        
                <apex:column headerValue="Key Mgmt">
                    <apex:inputField value="{!opp.Key_Management__c}" style="text-align:right;width:60px"/>
                </apex:column>
                <apex:column headerValue="Services">
                    <apex:inputField value="{!opp.Services__c}" style="text-align:right;width:60px"/>
                </apex:column>
                
                <apex:column headerValue="Other">
                    <apex:inputField value="{!opp.Other__c}" style="text-align:right;width:60px"/>
                </apex:column>
               <!-- <apex:column headerValue="Fire D&A">
                    <apex:inputField value="{!opp.Fire_D_A__c}" style="width:60px"/>
                </apex:column>  -->
                <!-- <apex:column headerValue="FireD&A HighHazards">
                    <apex:inputField value="{!opp.Fire_D_A_High_Hazards__c}" style="width:60px"/>
                </apex:column> -->
   
                <!-- <apex:column headerValue="Suppression">
                    <apex:inputField value="{!opp.Suppression__c}" style="width:60px"/>
                </apex:column>  --> 

            </apex:pageBlockTable>            
            
           
        </apex:pageBlock>
    </apex:form>
    </body>
    <div class="lightbox"></div>
</apex:page>

My class is ; 
public with sharing class OppRecordSetVarController4 {  
    
    private final Integer pageSize = 5;
    public integer pageNumber = 1; 
    public boolean lastPage = false;
    private final String Could_Not_Save_Modified_Records = 'You have changed some values of the below records but did not save, please review the changes and "Save" the records then proceed.Otherwise “Cancel” to discard all pending changes.'; 
    public transient Map<String, Decimal> probabilityStageNameMap;   
    ApexPages.StandardSetController controller;
    ApexPages.StandardSetController controller2;
    public List<Opportunity> oppList{get;set;}
    PageReference pg;
    public boolean pbt1{get;set;}
    public boolean pbt2{get;set;}
    private String sortDirection = 'ASC';
    private String sortExp = 'name';
    public List<Opportunity> sortedOppList{get;set;}
    public Set<Opportunity> sortedOppSet {get;set;}
   
    
    public OppRecordSetVarController4(ApexPages.StandardSetController controller) {  
        this.controller = controller;
        controller.setPageSize(pageSize);
        oppList = new List<Opportunity>(); 
        //oppList = controller.getRecords(); 
       // pbt1 = true;
        //pbt2= false;  
        
        //while(controller.getHasNext()){
        
           // for(Opportunity o: (List<Opportunity>) controller.getRecords()){
                //oppList.add(o);
            //}
            //controller.next();            
        //}  
        
        getoppList();
    } 
    
    //**** Sorting Properties Starts****//
    public String sortExpression
    {
     get
     {
        return sortExp;
     }
     set
     {
       //if the column is clicked on then switch between Ascending and Descending modes
       if (value == sortExp)
         sortDirection = (sortDirection == 'ASC')? 'DESC' : 'ASC';
       else
         sortDirection = 'ASC';
       sortExp = value;
     }
    }
    
    public String getSortDirection()
    {
    //if not column is selected 
    if (sortExpression == null || sortExpression == '')
      return 'ASC';
    else
     return sortDirection;
    }

    public void setSortDirection(String value)
    {  
      sortDirection = value;
    }
    
    
    public void doNext(){        
        try{
            controller.Next();
            //pageNumber++;
            //lastPage = false;
        }catch(Exception e){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.SEVERITY.WARNING,Could_Not_Save_Modified_Records));
        }
    }
     
    public void doPrevious(){        
        try{
            controller.Previous();
           // pageNumber--;
            //lastPage = false;
        }catch(Exception e){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.SEVERITY.WARNING,Could_Not_Save_Modified_Records));
        }
    }
        
    public void doFirst(){        
        try{
            controller.First();
            //pageNumber = 1;
            //lastPage = false;
        }catch(Exception e){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.SEVERITY.WARNING,Could_Not_Save_Modified_Records));
        }
    }
        
    public void doLast(){        
        try{
            controller.Last();
            //lastPage = true; 
            //pageNumber++;
            
        }catch(Exception e){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.SEVERITY.WARNING,Could_Not_Save_Modified_Records));
        }
    }
         
    public Boolean getHasPrevious(){             
        return this.controller.getHasPrevious(); 
    }
      
    public Boolean getHasNext(){         
        return this.controller.getHasNext();    
    } 
       
    public List<Opportunity> getOpportunities() {        
        //oppList = (List<Opportunity>) controller.getRecords();
        //System.debug('==oppList.size=='+oppList.size()); 
        return (List<Opportunity>) controller.getRecords();
    }
    
    public List<Opportunity> getOppList() {        
        oppList = (List<Opportunity>) controller.getRecords();
        System.debug('==oppList=='+oppList); 
        return oppList;
    }
    
    public PageReference changeStageName(){        
    if (probabilityStageNameMap == null) {
        probabilityStageNameMap = new Map<String, Decimal>();
        for (OpportunityStage oppStage : [Select MasterLabel, DefaultProbability
                                       From OpportunityStage]) {
           probabilityStageNameMap.put(oppStage.MasterLabel, oppStage.DefaultProbability);
        }
    }
  
    for(Opportunity op : oppList){   
    if (probabilityStageNameMap.containsKey(op.StageName)) {         
         op.Probability = probabilityStageNameMap.get(op.StageName);         
    }
    }
    return null;    
    }
    
    public void changeListView(){       
        controller.save();                   
    }
    
    public void ViewData() {
      
      pageNumber = controller.getPageNumber();
      while(controller.getHasNext()){
        
            for(Opportunity o: (List<Opportunity>) controller.getRecords()){
                oppList.add(o);
            }
            controller.next();            
      }  
      controller.setPageNumber(pageNumber);   
      //controller2 = new ApexPages.StandardSetController(oppList); 
      
    }
 
    public PageReference doSave(){   
    
    PageReference p;  
    try{
    pageNumber = controller.getPageNumber();
    p =  this.controller.save();
    //pageNumber = controller.getPageNumber();
    if(p != null){
        if(pageNumber != 1){  
            controller.setPageNumber(pageNumber -1);
            controller.next();
        }          
        //pg = ApexPages.currentPage();
        //pg.setRedirect(false);
        pg = new PageReference('/apex/OppListViewVFv3');

        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.CONFIRM, 'Records saved successfully!!')); 
        //}  
    }
    }catch(Exception exx){
        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, 'An error occured on the page.Please try again reloading the page.'));
    }
    return null;    
    } 
    
    public PageReference doCancel(){ 
    PageReference pgc;
   
    PageReference p =  this.controller.cancel();
    if(p != null){
        pgc = new PageReference('/apex/OppListViewVF');
    }
        return pgc;
    }
        
}



Thanks,
Bappa
 
  • October 30, 2014
  • Like
  • 0
Hi,

I have a requirement to display/provide download link to the http blob response in visualforce page.
I am able to create a new attachment/document from blob value and provide a download link to that in vf page using {!URLFOR($Action.Attachment.Download,ReportName)}".
But i dont want to create a new attachemnt, just pass it from apex to vf page.
Any ideas ?

Thanks
Sid

HI there,

it's really confusing that how it is picking values by using {!filterId}
expression selectList component???

<apex:page standardController="Case" recordSetvar="cases">
    <apex:pageBlock >
        <apex:form id="theForm">
            <apex:panelGrid columns="2">
                <apex:outputLabel value="View:"/>
                <apex:selectList value="{!filterId}" size="1">
                    <apex:actionSupport event="onchange" rerender="list"/>
                    <apex:selectOptions value="{!listviewoptions}"/>
                </apex:selectList>
            </apex:panelGrid>
            <apex:pageBlockSection >
                <apex:dataList var="c" value="{!cases}" id="list">
                    {!c.subject}
                </apex:dataList>
            </apex:pageBlockSection>
        </apex:form>
    </apex:pageBlock>
</apex:page>

if anyone knows it there than please update me..... thanks.. in advance :)

  • October 04, 2013
  • Like
  • 0

We have an Apex class that uses the 'getQueryLocator' to return a single page of results, 2000 records (single page max).

 

We are trying to implement:

    public ApexPages.StandardSetController getCampaignsSsc() {
        if (this.campaigns == null) {
            this.campaigns = new ApexPages.StandardSetController(
                Database.getQueryLocator([SELECT Id, Name, StartDate, EndDate, Type, Status, Description, Owner.Name, NumberOfLeads, NumberOfContacts, NumberOfOpportunities, NumberOfWonOpportunities, AmountAllOpportunities, Exclude_from_Calendar__c FROM Campaign ORDER BY StartDate DESC])
            );
            if(this.pagesize == null){
                this.pagesize = 2000;
            }
            this.campaigns.setPageSize(this.pagesize);
        return campaigns;
    }

 However, the campaign records always seem to come back sorted by Name is it possible I'm not setting something with the SSC before running the 'getRecords' operation that is causing them to always return this way (reguardless of the arguement in the ORDER BY clause)?

 

p.s. sorting the records on the server before returning them to the page isn't really an option as with 2000 records it would overflow the script statements limits.

Hi,

 

I have two unrelated objects where a specific column might have the same value in another object. I'm trying to find out if a value in an object, already exist in another object. I was reading up on a wrapper classes, but I couldn't get my head around it. Any idea how this is possible? 

 

For example I have the following two objects with the following fields

 

Object_1__c (id, Name, Status)

Object_2__c(id, Name, Area)

 

In SQL, it would be written something like below. Please NOTE that there are fields that need to be displayed from both objects.

 

SELECT o1.id, o1.Name, o1.Status, o2.Area FROM Object_1__c o1, Object_2__c o2 WHERE o1.Name = o2.Name

 

How many times a trigger will be executed when try to insert 1000 records to a standard object like Accounts. How to test this? Thank you very much in advance.