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.
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.
Hi, can you share how you set it as required via a business rule example?
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.
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:
Web API call and result for "name" column
/api/data/v9.0/EntityDefinitions(LogicalName='account')/Attributes(LogicalName='name')?$select=RequiredLevel
Web API call and result for "accountnumber" column
api/data/v9.0/EntityDefinitions(LogicalName='account')/Attributes(LogicalName='accountnumber')?$select=RequiredLevel
As you can see in my API call, I am leveraging the Column requirement level metadata property:
Hope that helps
Daivat Vartak (v-9d...
225
Super User 2025 Season 1
Eugen Podkorytov
106
Muhammad Shahzad Sh...
106
Most Valuable Professional