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 / Retrieve Entity Metada...
Power Pages
Unanswered

Retrieve Entity Metadata or Field Attributes in D365 Portal

(0) ShareShare
ReportReport
Posted on by 2

Hi, I am not able to find any documentation to retrieve entity metadata or entity's field attributes within the custom javascript of D365 Portal.

 

I would like to get the entity's field attribute's value (e.g. CanTriggerWorkflow: true) using web api and I tried what's in this link: https://carldesouza.com/retrieving-entity-metadata-in-dynamics-365-in-javascript/ but it doesn't give any results.

I believe it is working in CRM as <crm_url> but not in Portal as <portal_url>.

 

Appreciate your help on this.

Thank you.

Categories:
I have the same question (0)
  • Lucas001 Profile Picture
    2,429 Super User 2025 Season 2 on at

    Hi @HwUduiN,

     

    what you probably want to use is the CRUD Api for power pages.

    Have a look at that tutorial: https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&cad=rja&uact=8&ved=2ahUKEwibqdP148qCAxWSR_EDHf0XDwcQwqsBegQIDRAG&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D5PwLZd_HE30&usg=AOvVaw2TOajephGg0CYKBTnfFGmx&opi=89978449

     

    Or MS learn at: https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&cad=rja&uact=8&ved=2ahUKEwibqdP148qCAxWSR_EDHf0XDwcQFnoECBUQAQ&url=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fpower-pages%2Fconfigure%2Fwrite-update-delete-operations&usg=AOvVaw25se7OSXNb-JaZ-5I1MfLV&opi=89978449

     



    --------------------------------------------------------------------------------------

    Hope that helps.

    If the post solves your problem, please mark it as solution. If it helps, consider a thumbs up.

  • Fubar Profile Picture
    8,344 Super User 2025 Season 2 on at

    Also note, the Portals Web API is not 100% the same as the CRM/Dynamics 365/Dataverse API (not everything in the Dataverse API is exposed in the Web API).

  • riko4 Profile Picture
    2 on at

    Hi, I really appreciate your answers but what I want to achieve is something like this in portal custom Javascript&colon;

    // Retrieve entity metadata
     $.ajax({
     type: "GET",
     contentType: "application/json; charset=utf-8",
     datatype: "json",
     url: webApiUrl + 'EntityDefinitions(LogicalName=\'' + entityLogicalName + '\')?$select=EntityId',
     beforeSend: function (xhr) {
     xhr.setRequestHeader("OData-MaxVersion", "4.0");
     xhr.setRequestHeader("OData-Version", "4.0");
     xhr.setRequestHeader("Accept", "application/json");
     xhr.setRequestHeader("Prefer", "odata.include-annotations=*");
     },
     success: function (entityMetadata) {
     var entityId = entityMetadata.EntityId;
    
     // Retrieve attribute metadata
     $.ajax({
     type: "GET",
     contentType: "application/json; charset=utf-8",
     datatype: "json",
     url: webApiUrl + 'EntityDefinitions(' + entityId + ')?$select=LogicalName&$expand=Attributes($filter=LogicalName eq \'' + attributeLogicalName + '\')',
     beforeSend: function (xhr) {
     xhr.setRequestHeader("OData-MaxVersion", "4.0");
     xhr.setRequestHeader("OData-Version", "4.0");
     xhr.setRequestHeader("Accept", "application/json");
     xhr.setRequestHeader("Prefer", "odata.include-annotations=*");
     },
     success: function (attributeMetadata) {
     var attribute = attributeMetadata.Attributes[0];
     var maxLength = attribute.MaxLength;
    
     console.log('Max length of ' + attributeLogicalName + ' field: ' + maxLength);
     },
     error: function (error) {
     console.error('Error retrieving attribute metadata:', error.statusText);
     }
     });
     },
     error: function (error) {
     console.error('Error retrieving entity metadata:', error.statusText);
     }
     });

     

    On the other hand, as expected, below piece of code is working when it runs within CRM but it is not applicable in portal: 

    req.open("GET", globalContext.getClientUrl() + "/api/data/v9.0/EntityDefinitions(LogicalName ..etc

     

     

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