web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / View counts of Record
Power Pages
Unanswered

View counts of Record

(0) ShareShare
ReportReport
Posted on by 56

Hi Everyone,

 

I have a field named view count and it should be updated numerically when ever a user open a record in the list view of a power pages page, when user opens a record first time of click of view details action button in the list view then the view count should update with 1 and if user opens same record for the 2nd time then the view count should update with 2 this is the scenario and it is working fine in the dynamics 365 on the on form load event of the form, you can find the dynamics 365 code below and I need it to work on the power pages portals page so can any one provide a solution to achieve this.

 

function updateViewCount() {
    var currentViewCount = Xrm.Page.getAttribute("new_viewcount").getValue();
    if (currentViewCount === null) {
        var newViewCount = 1;
    } else {
        var newViewCount = currentViewCount + 1;
    }
    Xrm.Page.getAttribute("new_viewcount").setValue(newViewCount);
    Xrm.Page.data.entity.save();
}
Xrm.Page.data.entity.addOnLoad(updateViewCount);

 

Thanks in advance..

Categories:
I have the same question (0)
  • oliver.rodrigues Profile Picture
    9,368 Most Valuable Professional on at

    If you want a single solution you would need to apply a plug-in on the Retrieve message, which is totally not recommended as it can lower the system performance.

     

    I would probably add a similar JS to the Portal that will perform that. Something like:

    $(document).ready(function(){
    
     let currentViewCount = $("#new_viewcount").val();
     $("#new_viewcount").val(currentViewCount + 1);
    });

     

     

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Pages

#1
Jerry-IN Profile Picture

Jerry-IN 71

#2
Fubar Profile Picture

Fubar 62 Super User 2025 Season 2

#3
sannavajjala87 Profile Picture

sannavajjala87 31

Last 30 days Overall leaderboard