Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!-- Create a placeholder table in which content updates will be posted -->
- <table id="contentUpdates">
- <thead>
- <tr>
- <th>Date</th>
- <th>Update(s)</th>
- </tr>
- </thead>
- <tbody>
- </tbody>
- </table>
- <!-- Execute logic to pull in and render recent content updates -->
- <script type="text/javascript">
- // Retrieve Content updated in the last 8 days
- var query =
- 'SELECT Id, Title, CreatedDate, LastModifiedDate ' +
- 'FROM ContentDocument ' +
- 'WHERE LastModifiedDate = LAST_N_DAYS:8 ' +
- 'ORDER BY LastModifiedDate DESC, Title ASC ';
- var results = sforce.connection.query(query);
- // Get a reference to the tbody element in which new content updates
- // are going to be displayed
- var table = document.getElementById("contentUpdates");
- var tbody = table.getElementsByTagName("tbody")[0];
- // Build the rows to present in the table, leveraging knowledge that
- // the query results are ordered by LastModifiedDate.
- var updateDate = null; // Used to determine whether a new row is needed
- for(var i = 0; i < results.records.length; i++) {
- var doc = results.records[i];
- var docModifiedDate = doc.LastModifiedDate.substring(0, 10);
- // We need to create a new row for each new date we encounter.
- // If you use a library like jQuery, the code can be even simpler
- if(docModifiedDate != updateDate) {
- var tr = document.createElement("tr");
- tbody.appendChild(tr);
- var dateHeader = document.createElement("th");
- dateHeader.innerHTML = docModifiedDate;
- tr.appendChild(dateHeader);
- var updatesCell = document.createElement("td");
- tr.appendChild(updatesCell);
- updateDate = docModifiedDate;
- }
- // Demonstrate the concept of adding the documents to the row
- // corresponding to the Last Modified Date
- updatesCell.innerHTML += doc.Title + "; ";
- }
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement