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 / Table is not showing i...
Power Pages
Unanswered

Table is not showing in power page preview

(1) ShareShare
ReportReport
Posted on by

Hi all,
I have developed a power page site to show a dataverse table using html code.
The Table is showing in development stage image is attached 

NeethuVenu_0-1720507524234.png

But while previewing the page the data is not displaying

NeethuVenu_1-1720507561558.png

The HTML  code which i have used is here 

<!DOCTYPE html>

<html lang="en">

<head>

  <meta charset="UTF-8">

  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <title>Employee Table</title>

  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">

  <style>

    .columnBlockLayout {

      padding: 16px;

      margin: 60px 0px;

      min-height: 200px;

    }

 

    .record-row {

      cursor: pointer;

    }

 

    .delete-button {

      background-color: #dc3545;

      color: white;

      border: none;

      padding: 5px 10px;

      border-radius: 4px;

      cursor: pointer;

    }

 

    .delete-button:hover {

      background-color: #c82333;

    }

  </style>

</head>

<body>

  <h1>Employee Table</h1>

 

  {% fetchxml data %}

  <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">

    <entity name="cr0a8_alzoneemptab">

      <attribute name="cr0a8_alzoneemptabid" />

      <attribute name="cr0a8_empid" />

      <attribute name="cr0a8_empname" />

      <attribute name="cr0a8_empage" />

      <order attribute="cr0a8_empid" descending="false" />

    </entity>

  </fetch>

  {% endfetchxml %}

 

  <div class="col-md-12 columnBlockLayout">

    {% if data.results.entities.size > 0 %}

    <table class="table">

      <thead>

        <tr>

          <th>EmpID</th>

          <th>EmpName</th>

          <th>EmpAge</th>

          <th>Action</th>

        </tr>

      </thead>

      <tbody>

        {% for results in data.results.entities %}

        <tr class="record-row" data-record-id="{{results.cr0a8_alzoneemptabid}}">

          <td>{{ results.cr0a8_empid }}</td>

          <td>{{ results.cr0a8_empname }}</td>

          <td>{{ results.cr0a8_empage }}</td>

          <td><button class="delete-button" data-id="{{results.cr0a8_alzoneemptabid}}">Delete</button></td>

        </tr>

        {% endfor %}

      </tbody>

    </table>

    {% else %}

    <p>No records found.</p>

    {% endif %}

  </div>

 

  <script>

    const tenantId = '7000c790-ec15-46b5-9b21-c47f8ff50c78';

    const clientId = 'be54b18f-a128-4d1f-b6ec-ee2d93375f25';

    const clientSecret = 'onS8Q~FhdWIpKTgSWJQUsegNs3Q1EvNNHGrxBaQw';

    const resource = 'https://org0c60e65e.crm8.dynamics.com/';

    const tokenEndpoint = `https://login.microsoftonline.com/${tenantId}/oauth2/v2.0/token`;

 

    async function getAccessToken() {

      const response = await fetch(tokenEndpoint, {

        method: 'POST',

        headers: {

          'Content-Type': 'application/x-www-form-urlencoded'

        },

        body: new URLSearchParams({

          client_id: clientId,

          scope: `${resource}/.default`,

          client_secret: clientSecret,

          grant_type: 'client_credentials'

        })

      });

 

      if (!response.ok) {

        throw new Error('Failed to obtain access token');

      }

 

      const data = await response.json();

      return data.access_token;

    }

 

    async function deleteRecord(recordId, accessToken) {

      const deleteUrl = `${resource}/api/data/v9.1/cr0a8_alzoneemptabs(${recordId})`;

 

      const response = await fetch(deleteUrl, {

        method: 'DELETE',

        headers: {

          'OData-MaxVersion': '4.0',

          'OData-Version': '4.0',

          'Accept': 'application/json',

          'Content-Type': 'application/json; charset=utf-8',

          'Authorization': `Bearer ${accessToken}`

        }

      });

 

      if (!response.ok) {

        const errorText = await response.text();

        throw new Error(`Failed to delete record: ${errorText}`);

      }

 

      alert('Record deleted successfully');

      location.reload();

    }

 

    document.addEventListener('DOMContentLoaded', function() {

      document.querySelectorAll('.delete-button').forEach(button => {

        button.addEventListener('click', async function() {

          const recordId = this.getAttribute('data-id');

          if (confirm('Are you sure you want to delete this record?')) {

            try {

              const accessToken = await getAccessToken();

              await deleteRecord(recordId, accessToken);

            } catch (error) {

              alert(`Error: ${error.message}`);

            }

          }

        });

      });

    });

  </script>

</body>

</html>

Can anybody help me on this?

Regards

Neethu

Categories:
I have the same question (0)
  • Ajlan Profile Picture
    235 on at

    @NeethuVenu Hello
    Please check the Table Permission. From the screenshot, I can see you're trying to access the table "anonymously". Please check if your table has read access for anonymous users.

    Ajlan_0-1720703143918.png

     



    Cheers 
    If this post helps resolve your issue, please mark it as the Accepted Solution 

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