Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Unanswered

Metadata Requiered Fields From Web API for a Specific Form and Record

(0) ShareShare
ReportReport
Posted on by

Is it possible to check via JavaScript if all mandatory fields are filled in on another linked entity, where the scope of the mandatory fields is set on the form.

My first thought was to read out the metadata via the WebApi. However, I could only read them out with the scope entity. I was not able to read out the metadata for a specific data set where the mandatory fields are also defined in the scope form.

  • Community Member Profile Picture
    on at
    RE: Metadata Requiered Fields From Web API for a Specific Form and Record

    pastedimage1636385547834v1.png

    I think I have already found the solution.

    In the onSave event, I fill the current mandatory fields in another invisible field as a comma-separated list with the logical names. In addition, I have included another boolean field, which I mark to be able to distinguish whether the change comes from the UI or from a background process.

    In order to be able to check on the basis of the data record whether all mandatory fields on the form used have been filled, you can check which fields should be filled with a query on all fields. In a loop, you can then go through all the fields from the comma-separated list and see whether they are filled.

  • Ioannis Vrasenikis Profile Picture
    on at
    RE: Metadata Requiered Fields From Web API for a Specific Form and Record

    Hi, can you share how you set it as required via a business rule example?

  • Community Member Profile Picture
    on at
    RE: Metadata Requiered Fields From Web API for a Specific Form and Record

    Thanks for your answer and the detailed explanation it also helped me a bit in understanding how to find out if a field is needed in general.

    Unfortunately, it could not solve my problem completely, as it only checks which field is needed in general. In my case, the requirements change for each record. A business rule decides dynamically on the basis of values whether some fields are required or not.

    I noticed that the level on which this is recorded is the UI (form) and not the entity level as usual.

    Therefore, it is necessary to distinguish the query on the basis of the individual data record, whereby the respective form must also be taken into account, as these can also have different mandatory fields.

  • Ioannis Vrasenikis Profile Picture
    on at
    RE: Metadata Requiered Fields From Web API for a Specific Form and Record

    Hi DenisG,

    I am not sure if I completely understand your requirement and if there is a different approach to this, but I can think of below logic (I am illustrating an example with fields of the account table below):

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

    Step 1 On Form custom JS level, iterate through all fields present on the form. //if needed, determine the linked entity you need to look for attribute metadata as well

    Step 1. 1 For each field of the entity you need, you can query via web API if the field is mandatory like this: /api/data/v9.0/EntityDefinitions(LogicalName='{´LogicialNameOfTable')/Attributes(LogicalName='{LogicalNameOfField}')?$select=RequiredLevel

    Step 1.2 Custom business logic

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

    Regarding 1.1, please check below some screenshots of my Vanilla environment.

    My Column configuration on account entity:

    pastedimage1636367768774v1.png

    Web API call and result for "name" column

    /api/data/v9.0/EntityDefinitions(LogicalName='account')/Attributes(LogicalName='name')?$select=RequiredLevel

    pastedimage1636368182844v5.png

    Web API call and result for "accountnumber" column

    api/data/v9.0/EntityDefinitions(LogicalName='account')/Attributes(LogicalName='accountnumber')?$select=RequiredLevel

    pastedimage1636368059104v2.png

    As you can see in my API call, I am leveraging the Column requirement level metadata property:

    https://docs.microsoft.com/en-us/powerapps/developer/data-platform/entity-attribute-metadata#column-requirement-level

    Hope that helps

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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Daivat Vartak (v-9davar) Profile Picture

Daivat Vartak (v-9d... 225 Super User 2025 Season 1

#2
Eugen Podkorytov Profile Picture

Eugen Podkorytov 106

#2
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 106 Most Valuable Professional

Overall leaderboard

Product updates

Dynamics 365 release plans