function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SRILAKSHMI BSRILAKSHMI B 

display latest record in pageblock table.

Hi,

 

I want to dosplay the approval history  of  a record  on a visualforce page in a Pageblock table.I am able to do the same by querying ProcessInstanceStep and providing TargetObject Id in where clause.

 

But I am not able to display the latest in the first row.I have used ORDER BY createdDate but still I am not able to view the latest on first row.Can anyone please how this can be sorted out.

 

Thanks,

Srilakshmi B

 

bob_buzzardbob_buzzard

Does that mean that when you order by in your soql query that the records don't come back in the expected order, or does the order get lost during your processing?

 

I'd expect order by to be the solution for this - can you post your code?

SRILAKSHMI BSRILAKSHMI B

Hi,

 

Thanks for your reply.ORDER BY works but I have embedded the VF page in the standard Pagelayout.Whenever I view the page I want the VF page to be refreshed since it is not refreshing I am not able to see the latest record.

 

Can you please tell me how to refresh the vf page on the standard pagelayout when record is viewed.

If you could provide a code sample that would be more helpful.

 

Thanks,

Srilakshmi B

bob_buzzardbob_buzzard

The VF page should refresh when embedded into a standard record view page.  When you navigate to the page the VF will be generated at that time.  How are you adding the new record?  

ANKITAANKITA

Page:

<apex:page controller="recentrecordcon">
  <apex:form >
      <apex:pageBlock >
          <apex:pageBlockSection >
              <apex:pageBlockTable value="{!recs}" var="r">
                  <apex:column headerValue="Name">
                      {!r.name}
                  </apex:column>
              </apex:pageBlockTable>
          </apex:pageBlockSection>
      </apex:pageBlock>
  </apex:form>
</apex:page>

 

Class

 

public with sharing class recentrecordcon {

    List<DataLoadTest__c> lstdlt=new List<DataLoadTest__c>();
    public List<DataLoadTest__c> getRecs() {
        lstdlt=[select Id,createddate,name from DataLoadTest__c order by createddate desc limit 1];
        return lstdlt;
    }

}

 

 

Try this.

Enter Record and save it.

Goto VF page and refresh. The recent entered record will be displayed at the top.

If this not solve your problem, let me know i will give another solution.

 

 

Thanks,

ANKITA

SRILAKSHMI BSRILAKSHMI B

Thanks for your solution.My requirement is something like this.

I want to display approval history records of a record on the record detail page.Due to some requirement  reasons I cannot use the standard approval history relatedlist on the detail page of a record.

 

For this, I have created a visualforce page where I am querying approval history list of a record and displaying it on the pageblocktable.

 

Now i have embedded this visualforce page into section of the pagelayout.Whenever user view the deatail page of the record  VF page should get refreshed and he should see the latest approval history for that record.

 

Though ORDER BY clause solves the problem of displaying latest records in pageblock table since VF page is not reloading when detail page is viewed, latest record is not displayed.

 

Please suggest me if you have any solution for this.

 

Thanks,

Srilakshmi B

bob_buzzardbob_buzzard

The visualforce page will refresh when the record is viewed though - that's the bit I don't understand here.

 

How is the user viewing the record detail?  Are you expecting it to update automatically without the user having to reload the page or similar?

SRILAKSHMI BSRILAKSHMI B

Hi,

 

Here user views the record as the way normal salesforce record is viewed.

 

Since I have embedded VF page into standrad pagelayout of the record.I want this VF page also should get refreshed automatically  whenever record is viewed.

 

 

Let me know if you can suggest any ideas to acheive this.

 

 

Thanks,

Srilakshmi B

jayanti mohantyjayanti mohanty

i want to show the available id whenever i m reloading the page...here i m using account as a standard object and i wanted to show the id of  custom object,which are available only...how can i do this?

bob_buzzardbob_buzzard

I'm really struggling to understand why the latest information wouldn't be pulled in to the page.  Visualforce pages don't get cached in that way, so each time you load the record view, the VF page will be created from scratch, meaning that the constructor will be executed and the SOQL run to pull the latest value through.

bob_buzzardbob_buzzard

Can you post your page and controller - that may help shed some light.

SRILAKSHMI BSRILAKSHMI B

Thanks for all your replies.I have made mistake in the query along with the ORDER BY I have not used DESC.

It was not problem with page reloading you are correct page is getting refreshed automatically when page is viewed.

 

Thanks the  problem is solved.

bob_buzzardbob_buzzard

Thanks for updating us.